Sha256: 45f529a72972aad1949000273ba1808cd25def01bd551abbcaeb4b5b94cfb830

Contents?: true

Size: 1.57 KB

Versions: 185

Compression:

Stored size: 1.57 KB

Contents

import PhoneNumber from './phone-number';

describe('PhoneNumber()', () => {
  test('cleans the number', () => {
    const phone = new PhoneNumber('(123) 456-7890');
    expect(phone.number()).toEqual('1234567890');
  });

  xtest('cleans numbers with dots', () => {
    const phone = new PhoneNumber('123.456.7890');
    expect(phone.number()).toEqual('1234567890');
  });

  xtest('cleans numbers with multiple spaces', () => {
    const phone = new PhoneNumber('123 456   7890   ');
    expect(phone.number()).toEqual('1234567890');
  });

  xtest('invalid when 9 digits', () => {
    const phone = new PhoneNumber('123456789');
    expect(phone.number()).toEqual(null);
  });

  xtest('invalid when 11 digits', () => {
    const phone = new PhoneNumber('21234567890');
    expect(phone.number()).toEqual(null);
  });

  xtest('valid when 11 digits and starting with 1', () => {
    const phone = new PhoneNumber('11234567890');
    expect(phone.number()).toEqual('1234567890');
  });

  xtest('invalid when 12 digits', () => {
    const phone = new PhoneNumber('321234567890');
    expect(phone.number()).toEqual(null);
  });

  xtest('invalid with letters', () => {
    const phone = new PhoneNumber('123-abc-7890');
    expect(phone.number()).toEqual(null);
  });

  xtest('invalid with punctuations', () => {
    const phone = new PhoneNumber('123-@:!-7890');
    expect(phone.number()).toEqual(null);
  });

  xtest('invalid with right number of digits but letters mixed in', () => {
    const phone = new PhoneNumber('1a2b3c4d5e6f7g8h9i0j');
    expect(phone.number()).toEqual(null);
  });
});

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.138 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.137 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.136 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.135 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.134 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.133 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.132 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.131 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.130 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.129 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.128 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.127 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.126 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.125 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.124 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.123 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.122 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.121 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.120 tracks/ecmascript/exercises/phone-number/phone-number.spec.js