-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathutility.js
34 lines (26 loc) · 1 KB
/
utility.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require('./support');
const {normalizeLanguageCode, matchesWord} = require('../src/utility');
describe('The Utility file', function() {
describe('normalizeLanguageCode method', function() {
it('should consider all of these valid', function() {
['en-us', 'en-US', 'de_de', 'de_DE'].map((x) => normalizeLanguageCode(x));
});
});
describe('matchesWord method', function() {
it('should match latin', function() {
expect(matchesWord('water')).to.be.deep.equal(['water']);
});
it('should match russian', function() {
expect(matchesWord('Москва')).to.be.deep.equal(['Москва']);
});
it('should match japanese', function() {
expect(matchesWord('北京市')).to.be.deep.equal(['北京市']);
});
it('should match arabic', function() {
expect(matchesWord('إسرائيل')).to.be.deep.equal(['إسرائيل']);
});
it('should not match nonsense', function() {
expect(matchesWord('!@#$')).to.be.deep.equal(null);
});
});
});