Skip to content

Commit

Permalink
test(test): Add various phone numbers in different format for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
perchiks committed Apr 2, 2018
1 parent a320bc4 commit 5fc3337
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
14 changes: 10 additions & 4 deletions dist/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ var tests = [{
pattern: '+ _ -'
}];

describe('Using different options', function () {
tests.forEach(function (item) {
it('Should return value in correct pattern: ' + item.pattern, function () {
assert.equal((0, _vueE.filter)('79999757065', item), item.answer);
var testPhones = ['79999757065', '7-999-975-7065', '7-999-975-70-65', '7-(999)-975-70-65', '7(999)975-70-65', '7 999 975 70 65', '7 (999) 975 70 65', '+79999757065', '+7-999-975-7065', '+7-999-975-70-65', '+7-(999)-975-70-65', '+7(999)975-70-65', '+7 999 975 70 65', '7 (999) 975 70 65'];

testPhones.forEach(function (phone) {
describe('Test defferent phone numbers : ' + phone, function () {
describe('Using different options: ', function () {
tests.forEach(function (item) {
it('Should return value in correct pattern: ' + item.pattern, function () {
assert.equal((0, _vueE.filter)(phone, item), item.answer);
});
});
});
});
it('Should return empty string for empty string', function () {
Expand Down
49 changes: 36 additions & 13 deletions src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,41 @@ const tests = [
}
]

describe('Using different options', () => {
tests.forEach((item) => {
it(`Should return value in correct pattern: ${item.pattern}`, () => {
assert.equal(filter('79999757065', item), item.answer)
let testPhones = [
'79999757065',
'7-999-975-7065',
'7-999-975-70-65',
'7-(999)-975-70-65',
'7(999)975-70-65',
'7 999 975 70 65',
'7 (999) 975 70 65',
'+79999757065',
'+7-999-975-7065',
'+7-999-975-70-65',
'+7-(999)-975-70-65',
'+7(999)975-70-65',
'+7 999 975 70 65',
'7 (999) 975 70 65'
]

testPhones.forEach((phone) => {
describe(`Test different phone numbers : ${phone}`, () => {
describe(`Using different options: `, () => {
tests.forEach((item) => {
it(`Should return value in correct pattern: ${item.pattern}`, () => {
assert.equal(filter(phone, item), item.answer)
})
})

})
})
it('Should return empty string for empty string', () => {
assert.equal(filter('', {
plus: true,
brackets: false,
space: true,
dash: false
}), '')
})
})
it('Should return empty string for empty string', () => {
assert.equal(filter('', {
plus: true,
brackets: false,
space: true,
dash: false
}), '')
})
})

0 comments on commit 5fc3337

Please # to comment.