question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Phone-number test cases are incorrect.

See original GitHub issue

On the phone-number exercise in the ecmascript track, acceptable phone numbers are explained in the read.me to be of the format NXX NXX XXXX (with no spaces), where N is any digit from 2-9 (no zero or 1) and X is any digit from 0-9.

Four of the test cases use the phone number 123 456 7890, which does not fit the pattern. Changing those test cases to 223 456 7890 makes them compliant with the requirements. This is the way that the tests were previously written in the javascript track. The following updated test cases fixes the issue.

import PhoneNumber from './phone-number';

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

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

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

  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('12234567890');
    expect(phone.number()).toEqual('2234567890');
  });

  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);
  });
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
LyleCharlesScottcommented, Sep 9, 2018

K! I didn’t realize I had to fork it, not just clone it. Pull request is up, with detailed documentation about what I did.

The example.js file is broken though. The version from the deprecated ecmascript track doesn’t have all of the functionality that the older one from the javascript track had. I think I’m going to try to update that now because it’s a relatively simple refactor.

Edit: I went ahead and fixed that also and send an additional pull request for it.

BTW Thanks so much for working with me on this and making me feel included. I love Exercism 😃

1reaction
LyleCharlesScottcommented, Sep 8, 2018

Ah! I didn’t see your reply until now. Sure, I’ll set up a PR for it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Write Phone Number Validation Test Cases - Accelatest
Easily complete your Phone Number Validation Test Cases with 17 ... Validate error messages are thrown when invalid data is entered.
Read more >
Test Cases For the Mobile Number Field
In this article, we will discuss some core test cases related to the Mobile Number Field. Test cases may vary from scenario to...
Read more >
Test Cases For Mobile Number field - QA acharya
Here! The important test cases for mobile number field given. Verify the mobile number text field by entering the valid 10-digit mobile number...
Read more >
How to design test cases for phone number and email input ...
How to design test cases for phone number and email input fields? · TC1: Submit with all valid fields. Negative functionality: · TC2:...
Read more >
How To Verify Phone Number During Tests Part 1
We want to verify the user via a phone number to avoid bots and spam accounts. ... The wrong verification code leads to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found