@@ -50,13 +50,22 @@ describe("Utils", () => {
50
50
expect ( types . isObject ( 1 ) ) . toBeFalsy ( )
51
51
} )
52
52
53
+ it ( "Should return true if the value is a bigint" , ( ) => {
54
+ expect ( types . isBigInt ( BigInt ( 1 ) ) ) . toBeTruthy ( )
55
+ } )
56
+
57
+ it ( "Should return false if the value is not a bigint" , ( ) => {
58
+ expect ( types . isBigInt ( 1 ) ) . toBeFalsy ( )
59
+ } )
60
+
53
61
it ( "Should return true if the value type is the one expected" , ( ) => {
54
62
expect ( types . isType ( 1 , "number" ) ) . toBeTruthy ( )
55
63
expect ( types . isType ( "string" , "string" ) ) . toBeTruthy ( )
56
64
expect ( types . isType ( ( ) => true , "function" ) ) . toBeTruthy ( )
57
65
expect ( types . isType ( [ ] , "array" ) ) . toBeTruthy ( )
58
66
expect ( types . isType ( new Uint8Array ( [ ] ) , "uint8array" ) ) . toBeTruthy ( )
59
67
expect ( types . isType ( { } , "object" ) ) . toBeTruthy ( )
68
+ expect ( types . isType ( BigInt ( 1 ) , "bigint" ) ) . toBeTruthy ( )
60
69
} )
61
70
62
71
it ( "Should return false if the value type is not the one expected or is not supported" , ( ) => {
@@ -66,6 +75,7 @@ describe("Utils", () => {
66
75
expect ( types . isType ( 1 , "array" ) ) . toBeFalsy ( )
67
76
expect ( types . isType ( 1 , "uint8array" ) ) . toBeFalsy ( )
68
77
expect ( types . isType ( 1 , "object" ) ) . toBeFalsy ( )
78
+ expect ( types . isType ( 1 , "bigint" ) ) . toBeFalsy ( )
69
79
expect ( types . isType ( 1 , "type" as any ) ) . toBeFalsy ( )
70
80
} )
71
81
@@ -163,6 +173,18 @@ describe("Utils", () => {
163
173
expect ( fun ) . not . toThrow ( )
164
174
} )
165
175
176
+ it ( "Should throw an error if the parameter is not a bigint" , ( ) => {
177
+ const fun = ( ) => errors . requireBigInt ( 1 as any , "parameter" )
178
+
179
+ expect ( fun ) . toThrow ( "Parameter 'parameter' is not a bigint" )
180
+ } )
181
+
182
+ it ( "Should not throw an error if the parameter is a bigint" , ( ) => {
183
+ const fun = ( ) => errors . requireBigInt ( BigInt ( 1 ) , "parameter" )
184
+
185
+ expect ( fun ) . not . toThrow ( )
186
+ } )
187
+
166
188
it ( "Should throw an error if the parameter is neither a function nor a number" , ( ) => {
167
189
const fun = ( ) => errors . requireTypes ( "string" , "parameter" , [ "function" , "number" ] )
168
190
0 commit comments