-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
58 lines (47 loc) · 1.71 KB
/
test.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var assert = require('assert');
var locale = require('./');
describe('locale-string', function(){
describe('locale-string()', function(){
it('should return undefined for an unrecognized `language`', function(){
var res = locale('Dubstep', 'United States');
assert(res === undefined);
});
it('should return undefined for an unrecognized `language`', function(){
var res = locale('English', 'Murica');
assert(res === undefined);
});
it('should return a correct locale string', function(){
var res = locale('Finnish', undefined);
assert.equal(res, 'fi');
});
it('should return a correct locale string', function(){
var res = locale('Italian', 'Italy');
assert.equal(res, 'it-IT');
});
});
describe('.parse()', function(){
it('should return undefined for an unrecognized `language`', function(){
var res = locale.parse('zz-US');
assert(res === undefined);
});
it('should return undefined for an unrecognized `country`', function(){
var res = locale.parse('en-GZ');
assert(res === undefined);
});
it('should return a correct locale string', function(){
var res = locale.parse('it-IT');
assert.equal(res.language, 'Italian');
assert.equal(res.country, 'Italy');
});
it('should return a correct language but undefined country for a dashless string', function(){
var res = locale.parse('fi');
assert.equal(res.language, 'Finnish');
assert(res.country === undefined);
});
it('should return undefined for a bad string', function(){
assert(!locale.parse('too-long-string'));
assert(!locale.parse('-'));
assert(!locale.parse('foo-'));
});
});
});