@@ -18,13 +18,25 @@ describe('parseNumber', () => {
18
18
it ( 'returns 0 if input is undefined and nullishNumber is true' , ( ) => {
19
19
const warnSpy = jest . spyOn ( console , 'warn' ) ;
20
20
expect ( parseNumber ( undefined , true ) ) . toBe ( 0 ) ;
21
- expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseNumber: got undefined input' ) ;
21
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseNumber: got nullish input' ) ;
22
+ } ) ;
23
+
24
+ it ( 'returns 0 if input is an empty string and nullishNumber is true' , ( ) => {
25
+ const warnSpy = jest . spyOn ( console , 'warn' ) ;
26
+ expect ( parseNumber ( '' , true ) ) . toBe ( 0 ) ;
27
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseNumber: got nullish input' ) ;
22
28
} ) ;
23
29
24
30
it ( 'returns undefined and warns if input is undefined and nullishNumber is false' , ( ) => {
25
31
const warnSpy = jest . spyOn ( console , 'warn' ) ;
26
32
expect ( parseNumber ( undefined , false ) ) . toBeUndefined ( ) ;
27
- expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseNumber: got undefined input' ) ;
33
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseNumber: got nullish input' ) ;
34
+ } ) ;
35
+
36
+ it ( 'returns undefined and warns if input is an empty string and nullishNumber is false' , ( ) => {
37
+ const warnSpy = jest . spyOn ( console , 'warn' ) ;
38
+ expect ( parseNumber ( '' , false ) ) . toBeUndefined ( ) ;
39
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseNumber: got nullish input' ) ;
28
40
} ) ;
29
41
30
42
it ( 'returns undefined and warns if parsing fails' , ( ) => {
@@ -56,13 +68,25 @@ describe('parseBoolean', () => {
56
68
it ( 'returns false if input is undefined and nullishBool is true' , ( ) => {
57
69
const warnSpy = jest . spyOn ( console , 'warn' ) ;
58
70
expect ( parseBoolean ( undefined , true ) ) . toBe ( false ) ;
59
- expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseBoolean: got undefined input' ) ;
71
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseBoolean: got nullish input' ) ;
72
+ } ) ;
73
+
74
+ it ( 'returns false if input is empty string and nullishBool is true' , ( ) => {
75
+ const warnSpy = jest . spyOn ( console , 'warn' ) ;
76
+ expect ( parseBoolean ( '' , true ) ) . toBe ( false ) ;
77
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseBoolean: got nullish input' ) ;
60
78
} ) ;
61
79
62
80
it ( 'returns undefined and warns if input is undefined and nullishBool is false' , ( ) => {
63
81
const warnSpy = jest . spyOn ( console , 'warn' ) ;
64
82
expect ( parseBoolean ( undefined , false ) ) . toBeUndefined ( ) ;
65
- expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseBoolean: got undefined input' ) ;
83
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseBoolean: got nullish input' ) ;
84
+ } ) ;
85
+
86
+ it ( 'returns undefined and warns if input is empty string and nullishBool is false' , ( ) => {
87
+ const warnSpy = jest . spyOn ( console , 'warn' ) ;
88
+ expect ( parseBoolean ( '' , false ) ) . toBeUndefined ( ) ;
89
+ expect ( warnSpy ) . toHaveBeenCalledWith ( 'parseBoolean: got nullish input' ) ;
66
90
} ) ;
67
91
68
92
it ( 'returns undefined and warns if parsing fails' , ( ) => {
0 commit comments