Debian Codegraph @

src/full.test.js

raw symbols SCIP
1 /* eslint-env jest */
2
3 import * as api from './full';
4
5 describe('full', function fullTestSuite() {
6
7 /* eslint-disable no-magic-numbers */
8
9 describe('getWeekStartByRegion(regionCode)', () => {
10 // eslint-disable-next-line require-jsdoc
11 function verify(code, expected) {
12 expect( api.getWeekStartByRegion(code) )
13 .toBe( expected );
14 }
15
16 it('should return correct result for ISO 3166 Alpha-2 code', () => {
17 verify('Bd', 0);
18 verify('bs', 0);
19 verify('PE', 0);
20 verify('kw', 6);
21 verify('SD', 6);
22 verify('mv', 5);
23 verify('no', 1);
24 verify('RU', 1);
25 });
26
27 it('should return correct result for ISO 3166 Alpha-3 code', () => {
28 verify('can', 0);
29 verify('SLV', 0);
30 verify('dji', 6);
31 verify('QAT', 6);
32 verify('MDV', 5);
33 verify('esp', 1);
34 verify('MUS', 1);
35 });
36
37 it('should return correct result for ISO 3166 numeric code', () => {
38 verify(446, 0);
39 verify(710, 0);
40 verify(400, 6);
41 verify(729, 6);
42 verify(462, 5);
43 verify(246, 1);
44 verify(686, 1);
45 });
46
47 it('should return 1', () => {
48 verify(null, 1);
49 verify(0, 1);
50 verify('moon', 1);
51 });
52 });
53
54 describe('getWeekStartByLocale(locale)', () => {
55 // eslint-disable-next-line require-jsdoc
56 function verify(locale, expected) {
57 expect( api.getWeekStartByLocale(locale) )
58 .toBe( expected );
59 }
60
61 it('should return correct result for locale containing only language code', () => {
62 verify('ccp', 0);
63 verify('HI', 0);
64 verify('jam', 0);
65 verify('FA', 6);
66 verify('bej', 6);
67 verify('HR', 1);
68 verify('vi', 1);
69 });
70
71 it('should return correct result for locale containing only language code and script', () => {
72 verify('TG-Arab', 0);
73 verify('Tg_Cyrl', 1);
74 verify('az-arab', 6);
75 verify('az_Cyrl', 1);
76 verify('UZ-ARAB', 6);
77 verify('Uz-latn', 1);
78 verify('Pa-Arab', 0);
79 verify('haz_DEVA', 6);
80 });
81
82 it('should return correct result for locale containing only script', () => {
83 verify('Arab', 6);
84 verify('deva', 0);
85 verify('cyrl', 1);
86 verify('Hans', 1);
87 verify('hant', 0);
88 verify('LATN', 1);
89 verify('Tfng', 1);
90 verify('THAA', 5);
91 });
92
93 it('should return correct result for locale containing only language and region code', () => {
94 verify('ar-sa', 0);
95 verify('en_NG', 1);
96 verify('FR-DZ', 6);
97 verify('es_mx', 0);
98 verify('BN-in', 0);
99 });
100
101 it('should return correct result for locale containing only script and region code', () => {
102 verify('ARAB_IN', 0);
103 verify('arab-IR', 6);
104 verify('Arab_MN', 1);
105 verify('Hant_MY', 1);
106 verify('latn_PY', 0);
107 });
108
109 it('should return correct result for locale containing language, script and region code', () => {
110 verify('az-arab-iq', 6);
111 verify('az_Arab-TR', 1);
112 verify('Az-Cyrl_Ru', 1);
113 verify('zh_Hant_tw', 0);
114 verify('ZH-HANT_VN', 1);
115 });
116
117 it('should return correct result for arbitrary locale', () => {
118 verify('xyz', 1);
119 verify('az_arab_IRA', 1);
120 verify('HI-Fij', 1);
121 verify('MS_SG_u-data', 0);
122 verify('en-mv-t-true-DE', 5);
123 });
124
125 it('should return 1', () => {
126 verify(false, 1);
127 verify('', 1);
128 verify('some-strange-locale', 1);
129 verify('Summer moved on', 1);
130 });
131 });
132 });