@@ -63,20 +63,22 @@ describe('PermissionRequest', () => {
6363 } ) ;
6464
6565 describe ( '/GET get' , ( ) => {
66- it ( 'Should return 404 when request does not exist' , async ( ) => {
66+ it ( 'Should return empty array when request does not exist' , async ( ) => {
6767 const userId = new mongoose . Types . ObjectId ( ) ;
6868 setTokenStatus ( true , { _id : userId , email : 'test@test.com' , accessLevel : 'MEMBER' } ) ;
69- const res = await test . sendGetRequest ( '/api/PermissionRequest/get?type=' + PermissionRequestTypes . LED_SIGN ) ;
70- expect ( res ) . to . have . status ( NOT_FOUND ) ;
69+ const res = await test . sendGetRequest ( '/api/PermissionRequest/get?userId=' + userId + '&type=' + PermissionRequestTypes . LED_SIGN ) ;
70+ expect ( res ) . to . have . status ( OK ) ;
71+ expect ( res . body ) . to . be . an ( 'array' ) . that . is . empty ;
7172 } ) ;
7273
7374 it ( 'Should return permission request when it exists' , async ( ) => {
7475 const userId = new mongoose . Types . ObjectId ( ) ;
7576 setTokenStatus ( true , { _id : userId , email : 'test@test.com' , accessLevel : 'MEMBER' } ) ;
7677 await new PermissionRequest ( { userId, type : PermissionRequestTypes . LED_SIGN } ) . save ( ) ;
77- const res = await test . sendGetRequest ( '/api/PermissionRequest/get?type=' + PermissionRequestTypes . LED_SIGN ) ;
78+ const res = await test . sendGetRequest ( '/api/PermissionRequest/get?userId=' + userId + '& type=' + PermissionRequestTypes . LED_SIGN ) ;
7879 expect ( res ) . to . have . status ( OK ) ;
79- expect ( res . body . type ) . to . equal ( PermissionRequestTypes . LED_SIGN ) ;
80+ expect ( res . body ) . to . be . an ( 'array' ) . with . length ( 1 ) ;
81+ expect ( res . body [ 0 ] . type ) . to . equal ( PermissionRequestTypes . LED_SIGN ) ;
8082 } ) ;
8183 } ) ;
8284
0 commit comments