-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(coverage): improve test coverage
- Loading branch information
1 parent
b1bfcb0
commit 1bdb6bf
Showing
8 changed files
with
127 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"plainjs", | ||
"plusplus", | ||
"scrollback", | ||
"skus", | ||
"snyk", | ||
"tseslint", | ||
"tsimp", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
import test from 'ava'; | ||
import * as wcutils from './wcutils.js'; | ||
|
||
test('wcutils normalizePhone() should convert special "no value" sentinels to "(none)"', (t) => { | ||
t.is(wcutils.normalizePhone('none'), '(none)'); | ||
t.is(wcutils.normalizePhone('na'), '(none)'); | ||
t.is(wcutils.normalizePhone('n/a'), '(none)'); | ||
t.is(wcutils.normalizePhone('no fax'), '(none)'); | ||
t.is(wcutils.normalizePhone('x'), '(none)'); | ||
t.is(wcutils.normalizePhone('xx'), '(none)'); | ||
t.is(wcutils.normalizePhone('xxx'), '(none)'); | ||
t.is(wcutils.normalizePhone(''), '(none)'); | ||
t.is(wcutils.normalizePhone(' '), '(none)'); | ||
t.is(wcutils.normalizePhone(' '), '(none)'); | ||
}); | ||
|
||
test('wcutils normalizePhone() should remove non-numeric characters for standard lengths', (t) => { | ||
t.is(wcutils.normalizePhone('123abc4567'), '123-4567'); | ||
t.is(wcutils.normalizePhone('123abc4567xyz890'), '(123) 456-7890'); | ||
}); | ||
test('wcutils normalizePhone()', (t) => { | ||
const cases: [string, string][] = [ | ||
// standard lengths/formatting | ||
['1234567', '123-4567'], | ||
['1234567890', '(123) 456-7890'], | ||
['11234567890', '(123) 456-7890'], | ||
// weird 9-digit cases.. | ||
['123456789', '(123) 45?-6789'], | ||
// weird 11-to-14-digit (not leading 1) cases... | ||
['92345678901', '(923) 456-7890 (+1)'], | ||
['923456789012', '(923) 456-7890 (+12)'], | ||
['9234567890123', '(923) 456-7890 (+123)'], | ||
['92345678901234', '(923) 456-7890 (+1234)'], | ||
// "no value" sentinels | ||
['none', '(none)'], | ||
['na', '(none)'], | ||
['n/a', '(none)'], | ||
['no fax', '(none)'], | ||
['x', '(none)'], | ||
['xx', '(none)'], | ||
['xxx', '(none)'], | ||
['', '(none)'], | ||
[' ', '(none)'], | ||
[' ', '(none)'], | ||
// non-numeric | ||
['123abc4567', '123-4567'], | ||
['123abc4567xyz890', '(123) 456-7890'], | ||
// unrecognized lengths | ||
['123abc', '123abc'], | ||
]; | ||
|
||
test('wcutils normalizePhone() should leave untouched for unrecognized lengths', (t) => { | ||
t.is(wcutils.normalizePhone('123abc'), '123abc'); | ||
cases.forEach(([input, expected], i) => { | ||
t.is(wcutils.normalizePhone(input), expected, `case ${i} "${input}"`); | ||
}); | ||
}); |