1
- import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
1
+ import { it } from 'vitest' ;
2
2
import hasLocale from './hasLocale.tsx' ;
3
3
4
4
it ( 'narrows down the type' , ( ) => {
@@ -24,72 +24,3 @@ it('can be called with a non-matching narrow candidate', () => {
24
24
candidate satisfies never ;
25
25
}
26
26
} ) ;
27
-
28
- describe ( 'accepts valid formats' , ( ) => {
29
- let consoleErrorSpy : ReturnType < typeof vi . spyOn > ;
30
-
31
- beforeEach ( ( ) => {
32
- consoleErrorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
33
- } ) ;
34
-
35
- afterEach ( ( ) => {
36
- consoleErrorSpy . mockRestore ( ) ;
37
- } ) ;
38
-
39
- it . each ( [
40
- 'en' ,
41
- 'en-US' ,
42
- 'EN-US' ,
43
- 'en-us' ,
44
- 'en-GB' ,
45
- 'zh-Hans-CN' ,
46
- 'es-419' ,
47
- 'en-Latn' ,
48
- 'zh-Hans' ,
49
- 'en-US-u-ca-buddhist' ,
50
- 'en-x-private1' ,
51
- 'en-US-u-nu-thai' ,
52
- 'ar-u-nu-arab' ,
53
- 'en-t-m0-true' ,
54
- 'zh-Hans-CN-x-private1-private2' ,
55
- 'en-US-u-ca-gregory-nu-latn' ,
56
- 'en-US-x-usd' ,
57
-
58
- // Somehow tolerated by Intl.Locale
59
- 'english'
60
- ] ) ( 'accepts: %s' , ( locale ) => {
61
- expect ( hasLocale ( [ locale ] as const , locale ) ) . toBe ( true ) ;
62
- expect ( consoleErrorSpy ) . not . toHaveBeenCalled ( ) ;
63
- } ) ;
64
- } ) ;
65
-
66
- describe ( 'warns for invalid formats' , ( ) => {
67
- let consoleErrorSpy : ReturnType < typeof vi . spyOn > ;
68
-
69
- beforeEach ( ( ) => {
70
- consoleErrorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
71
- } ) ;
72
-
73
- afterEach ( ( ) => {
74
- consoleErrorSpy . mockRestore ( ) ;
75
- } ) ;
76
-
77
- it . each ( [
78
- 'en_US' ,
79
- 'en-' ,
80
- 'e-US' ,
81
- 'en-USA' ,
82
- 'und' ,
83
- '123' ,
84
- '-en' ,
85
- 'en--US' ,
86
- 'toolongstring' ,
87
- 'en-US-' ,
88
- '@#$' ,
89
- 'en US' ,
90
- 'en.US'
91
- ] ) ( 'rejects: %s' , ( locale ) => {
92
- hasLocale ( [ locale ] as const , locale ) ;
93
- expect ( consoleErrorSpy ) . toHaveBeenCalled ( ) ;
94
- } ) ;
95
- } ) ;
0 commit comments