@@ -4,22 +4,32 @@ import { readdirSync } from 'node:fs'
4
4
import { Language } from '../utils/getLanguage'
5
5
import { includeAllKeys , excludeKeys } from './utils'
6
6
7
- const locales = readdirSync ( resolve ( __dirname , '../locales' ) )
7
+ const locales = readdirSync ( resolve ( __dirname , '../locales' ) ) . filter ( ( file ) => {
8
+ return file . includes ( '.json' ) // exclude unnecessary files
9
+ } )
10
+
11
+ describe ( 'should match name regex' , ( ) => {
12
+ locales . forEach ( ( locale ) => {
13
+ it ( `for ${ locale } ` , ( ) => {
14
+ expect ( locale ) . toMatch ( / ^ [ a - z A - Z ] { 2 } ( - [ a - z A - Z ] { 2 } ) * .j s o n $ / )
15
+ } )
16
+ } )
17
+ } )
8
18
9
19
describe ( 'should include full keys' , ( ) => {
10
- const structure : Language = require ( '../schema/locale.json' )
11
- locales . forEach ( ( locale ) => {
12
- it ( `for ${ locale } ` , ( ) => {
13
- expect ( includeAllKeys ( require ( `../locales/${ locale } ` ) , structure ) ) . toBeTruthy ( )
14
- } )
20
+ const structure : Language = require ( '../schema/locale.json' )
21
+ locales . forEach ( ( locale ) => {
22
+ it ( `for ${ locale } ` , ( ) => {
23
+ expect ( includeAllKeys ( require ( `../locales/${ locale } ` ) , structure ) ) . toBeTruthy ( )
15
24
} )
25
+ } )
16
26
} )
17
27
18
- describe ( "shouldn't include unnecessary keys" , ( ) => {
19
- const structure : Language = require ( '../schema/locale.json' )
20
- locales . forEach ( ( locale ) => {
21
- it ( `for ${ locale } ` , ( ) => {
22
- expect ( excludeKeys ( require ( `../locales/${ locale } ` ) , structure ) ) . toBeTruthy ( )
23
- } )
28
+ describe ( "should not include unnecessary keys" , ( ) => {
29
+ const structure : Language = require ( '../schema/locale.json' )
30
+ locales . forEach ( ( locale ) => {
31
+ it ( `for ${ locale } ` , ( ) => {
32
+ expect ( excludeKeys ( require ( `../locales/${ locale } ` ) , structure ) ) . toBeTruthy ( )
24
33
} )
25
- } )
34
+ } )
35
+ } )
0 commit comments