@@ -4,6 +4,7 @@ const { assert, expect } = require('chai')
4
4
const {
5
5
validateLocaleCode,
6
6
findCountryLanguages,
7
+ findCountryLocales,
7
8
} = require ( '../src' )
8
9
9
10
describe ( 'Validation tests.' , ( ) => {
@@ -24,11 +25,12 @@ describe('Validation tests.', () => {
24
25
} )
25
26
} )
26
27
27
- describe ( 'Code search tests.' , ( ) => {
28
+ describe ( 'Language code by country search tests.' , ( ) => {
28
29
it ( 'should return a list of languages' , ( done ) => {
29
30
const res = findCountryLanguages ( 'US' )
30
31
expect ( res ) . to . be . an ( 'array' )
31
32
expect ( res ) . to . have . lengthOf ( 2 )
33
+ expect ( res ) . to . deep . equal ( [ 'en' , 'es' ] )
32
34
done ( )
33
35
} )
34
36
@@ -47,3 +49,50 @@ describe('Code search tests.', () => {
47
49
} )
48
50
} )
49
51
52
+ describe ( 'Locale code by country search tests.' , ( ) => {
53
+ it ( 'should return a list of locales' , ( done ) => {
54
+ const res = findCountryLocales ( 'BE' )
55
+ expect ( res ) . to . be . an ( 'array' )
56
+ expect ( res ) . to . have . lengthOf ( 4 )
57
+ expect ( res ) . to . deep . equal ( [ 'de-BE' , 'en-BE' , 'fr-BE' , 'nl-BE' ] )
58
+ done ( )
59
+ } )
60
+
61
+ it ( 'should return an empty list' , ( done ) => {
62
+ const res = findCountryLocales ( 'YYY' )
63
+ expect ( res ) . to . be . an ( 'array' )
64
+ expect ( res ) . to . have . lengthOf ( 0 )
65
+ done ( )
66
+ } )
67
+
68
+ it ( 'should return an empty list again' , ( done ) => {
69
+ const res = findCountryLocales ( 77236 )
70
+ expect ( res ) . to . be . an ( 'array' )
71
+ expect ( res ) . to . have . lengthOf ( 0 )
72
+ done ( )
73
+ } )
74
+ } )
75
+
76
+ describe ( 'Locale code by country search tests.' , ( ) => {
77
+ it ( 'should return a list of locales' , ( done ) => {
78
+ const res = findCountryLocales ( 'BE' )
79
+ expect ( res ) . to . be . an ( 'array' )
80
+ expect ( res ) . to . have . lengthOf ( 4 )
81
+ expect ( res ) . to . deep . equal ( [ 'de-BE' , 'en-BE' , 'fr-BE' , 'nl-BE' ] )
82
+ done ( )
83
+ } )
84
+
85
+ it ( 'should return an empty list' , ( done ) => {
86
+ const res = findCountryLocales ( 'YYY' )
87
+ expect ( res ) . to . be . an ( 'array' )
88
+ expect ( res ) . to . have . lengthOf ( 0 )
89
+ done ( )
90
+ } )
91
+
92
+ it ( 'should return an empty list again' , ( done ) => {
93
+ const res = findCountryLocales ( 77236 )
94
+ expect ( res ) . to . be . an ( 'array' )
95
+ expect ( res ) . to . have . lengthOf ( 0 )
96
+ done ( )
97
+ } )
98
+ } )
0 commit comments