/
intl.test.js
57 lines (49 loc) 路 1.67 KB
/
intl.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
/*
* Titanium SDK
* Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');
describe('Intl', () => {
it('exists', () => should(Intl).not.be.undefined());
describe('#getCanonicalLocales()', () => {
it('is a Function', () => {
should(Intl.getCanonicalLocales).not.be.undefined();
should(Intl.getCanonicalLocales).be.a.Function();
});
it('no arguments', () => {
const locales = Intl.getCanonicalLocales();
should(locales).be.an.Array();
should(locales.length).be.eql(0);
});
it('String argument', () => {
const locales = Intl.getCanonicalLocales('EN-US');
should(locales).be.an.Array();
should(locales.length).be.eql(1);
should(locales[0]).be.eql('en-US');
});
it('Array argument with 1 String', () => {
const locales = Intl.getCanonicalLocales([ 'EN-US' ]);
should(locales).be.an.Array();
should(locales.length).be.eql(1);
should(locales[0]).be.eql('en-US');
});
it('Array argument with 2 Strings', () => {
const locales = Intl.getCanonicalLocales([ 'EN-US', 'DE-DE' ]);
should(locales).be.an.Array();
should(locales.length).be.eql(2);
should(locales[0]).be.eql('en-US');
should(locales[1]).be.eql('de-DE');
});
it('Array argument with 2 equivalent Strings', () => {
const locales = Intl.getCanonicalLocales([ 'EN-US', 'en-US' ]);
should(locales).be.an.Array();
should(locales.length).be.eql(1);
should(locales[0]).be.eql('en-US');
});
});
});