Skip to content

Commit

Permalink
feat(Testing): Add unit tests with Mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Mikhaylov authored Apr 2, 2018
1 parent 2498fbb commit e68659e
Show file tree
Hide file tree
Showing 9 changed files with 3,176 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"presets": [
["es2015", { "modules": false }]
["env", { "modules": false }]
],
"plugins": [
"external-helpers"
// "external-helpers"
]
}
11 changes: 0 additions & 11 deletions .flowconfig

This file was deleted.

3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"testEnvironment": "node"
}
70 changes: 70 additions & 0 deletions dist/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';

var _vueE = require('./vue-e164.js');

var assert = require('assert');

var tests = [{
plus: true,
brackets: true,
space: true,
answer: '+7 (999) 975 70 65',
pattern: '+ () _'
}, {
plus: false,
brackets: false,
space: false,
answer: '79999757065',
pattern: 'all options false'
}, {
plus: true,
brackets: false,
space: false,
answer: '+79999757065',
pattern: '+'
}, {
plus: true,
brackets: true,
space: false,
answer: '+7(999)9757065',
pattern: '+ ()'
}, {
plus: false,
brackets: true,
space: true,
answer: '7 (999) 975 70 65',
pattern: '() _'
}, {
plus: false,
brackets: false,
space: true,
answer: '7 999 975 70 65',
pattern: '_'
}, {
plus: false,
brackets: true,
space: false,
answer: '7(999)9757065',
pattern: '()'
}, {
plus: true,
brackets: false,
space: true,
answer: '+7 999 975 70 65',
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);
});
});
it('Should return empty string for empty string', function () {
assert.equal((0, _vueE.filter)('', {
plus: true,
brackets: false,
space: true
}), '');
});
});
4 changes: 2 additions & 2 deletions dist/vue-e164.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e68659e

Please # to comment.