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.159 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.158 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.157 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.156 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.155 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.154 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.153 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.152 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.151 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.150 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.149 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.148 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.147 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.146 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.145 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.144 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.143 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.142 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.141 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.140 tracks/ecmascript/exercises/phone-number/phone-number.spec.js