File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 77 fromBase58 ,
88 toBase58 ,
99 fromBase58Check ,
10- toBase58Check
10+ toBase58Check ,
11+ verifyNotNull
1112} from '../../primitives/utils'
1213
1314describe ( 'utils' , ( ) => {
@@ -207,3 +208,28 @@ describe('utils', () => {
207208 expect ( toArray ( input ) ) . toEqual ( expected )
208209 } )
209210} )
211+
212+ describe ( 'verifyNotNull' , ( ) => {
213+ it ( 'should return the value if it is not null or undefined' , ( ) => {
214+ expect ( verifyNotNull ( 42 ) ) . toBe ( 42 )
215+ expect ( verifyNotNull ( 'hello' ) ) . toBe ( 'hello' )
216+ expect ( verifyNotNull ( { } ) ) . toEqual ( { } )
217+ expect ( verifyNotNull ( [ ] ) ) . toEqual ( [ ] )
218+ } )
219+
220+ it ( 'should throw an error with default message if value is null' , ( ) => {
221+ expect ( ( ) => verifyNotNull ( null ) ) . toThrow ( 'Expected a valid value, but got undefined or null.' )
222+ } )
223+
224+ it ( 'should throw an error with default message if value is undefined' , ( ) => {
225+ expect ( ( ) => verifyNotNull ( undefined ) ) . toThrow ( 'Expected a valid value, but got undefined or null.' )
226+ } )
227+
228+ it ( 'should throw an error with custom message if value is null' , ( ) => {
229+ expect ( ( ) => verifyNotNull ( null , 'Custom error' ) ) . toThrow ( 'Custom error' )
230+ } )
231+
232+ it ( 'should throw an error with custom message if value is undefined' , ( ) => {
233+ expect ( ( ) => verifyNotNull ( undefined , 'Another custom error' ) ) . toThrow ( 'Another custom error' )
234+ } )
235+ } )
You can’t perform that action at this time.
0 commit comments