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.180 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.179 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.178 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.177 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.176 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.175 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.174 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.173 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.172 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.171 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.170 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.169 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.167 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.166 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.165 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.164 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.163 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.162 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.161 tracks/ecmascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.160 tracks/ecmascript/exercises/phone-number/phone-number.spec.js