@@ -3,16 +3,34 @@ var expect = require('chai').expect;
33
44describe ( 'non_object_values values' , function ( ) {
55
6- it ( 'should work with string' , function ( ) {
7- var token = jwt . sign ( 'hello' , '123' ) ;
8- var result = jwt . verify ( token , '123' ) ;
9- expect ( result ) . to . equal ( 'hello ') ;
6+ it ( 'should does not work with string' , function ( ) {
7+ expect ( function ( ) {
8+ jwt . sign ( 'hello' , '123' ) ;
9+ } ) . to . throw ( 'Payload must be valid JSON object ') ;
1010 } ) ;
1111
12- it ( 'should work with number' , function ( ) {
13- var token = jwt . sign ( 123 , '123' ) ;
14- var result = jwt . verify ( token , '123' ) ;
15- expect ( result ) . to . equal ( '123 ') ;
12+ it ( 'should does not work with number' , function ( ) {
13+ expect ( function ( ) {
14+ jwt . sign ( 123 , '123' ) ;
15+ } ) . to . throw ( 'Payload must be valid JSON object ') ;
1616 } ) ;
1717
18+ it ( 'should does not work with function' , function ( ) {
19+ expect ( function ( ) {
20+ jwt . sign ( function ( ) { return 0 } , '123' )
21+ } ) . to . throw ( 'Payload must be valid JSON object' )
22+ } )
23+
24+ it ( 'should does not work with boolean' , function ( ) {
25+ expect ( function ( ) {
26+ jwt . sign ( true , '123' )
27+ } ) . to . throw ( 'Payload must be valid JSON object' )
28+ } )
29+
30+ it ( 'should does not work with undefined' , function ( ) {
31+ expect ( function ( ) {
32+ jwt . sign ( undefined , '123' )
33+ } ) . to . throw ( 'Payload must be valid JSON object' )
34+ } )
35+
1836} ) ;
0 commit comments