Debian Codegraph @

src/api.test.js

raw symbols SCIP
1 /* eslint-env jest */
2
3 import * as api from './api';
4
5 describe('api', function apiTestSuite() {
6
7 /* eslint-disable no-magic-numbers */
8
9 describe('getWeekStartByRegion(regionCode, regionDayMap)', () => {
10 // eslint-disable-next-line require-jsdoc
11 function verify(code, map, expected) {
12 expect( api.getWeekStartByRegion(code, map) )
13 .toBe( expected );
14 }
15
16 it('should return result depending on regionDayMap', () => {
17 verify('png', {BR: 0, PNG: 3, EG: 6}, 3);
18 verify('Qa', {QA: 6}, 6);
19 verify(50, {BD: 5, '50': 5, SD: 6}, 5);
20 verify('PNG', {BR: 0, PNG: 11, EGY: 6}, 11);
21 });
22
23 it('should return 1', () => {
24 verify('Id', {}, 1);
25 verify('PR', {QA: 3, HK: 0}, 1);
26 });
27 });
28
29 describe('getWeekStartByLocale(locale, langRegionMap, regionDayMap)', () => {
30 // eslint-disable-next-line max-params, require-jsdoc
31 function verify(locale, langRegionMap, regionDayMap, expected) {
32 expect( api.getWeekStartByLocale(locale, langRegionMap, regionDayMap) )
33 .toBe( expected );
34 }
35
36 it('should return result depending on langRegionMap and regionDayMap', () => {
37 verify('no', {no: 'abc'}, {ABC: 3}, 3);
38 verify('no', {no: 'abc', yes: 'xyz'}, {ABC: 9, XYZ: 10}, 9);
39 verify('KK_arab', {'kk_arab': 'CN'}, {CN: 0}, 0);
40 verify('KK_Arab', {'kk_arab': 'CN', kk: 'DJ'}, {CN: 0, DJ: 6}, 0);
41 verify('kk_ARAB', {'kk_arab': 'CN', 'Arab': 'iq'}, {CN: 0, IQ: 6}, 0);
42 verify('fr-DZ', {fr: 'FR'}, {FR: 1, DZ: 6}, 6);
43 verify('fr-DZ', {fr: 'FR', dz: 'FR'}, {FR: 2, CA: 0, DZ: 6}, 6);
44 });
45
46 it('should return 1', () => {
47 verify('no', {}, {}, 1);
48 verify('no', {en: 'GB', fr: 'DZ'}, {GB: 5, DZ: 6}, 1);
49 verify('fr-DZ', {fr: 'FR'}, {FR: 3, TT: 0}, 1);
50 });
51 });
52 });