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.38 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.37 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.36 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.35 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.34 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.33 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.32 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.31 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.30 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.29 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.28 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.27 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.26 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.25 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.24 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.23 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.22 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.21 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.20 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.19 tracks/ecmascript/exercises/phone-number/phone-number.spec.js