@@ -49,7 +49,7 @@ describe("Logs", function () {
49
49
} ) ;
50
50
} ) ;
51
51
52
- describe ( "GET /logs/archive -details" , function ( ) {
52
+ describe ( "GET /logs/archived -details" , function ( ) {
53
53
let addLogsStub ;
54
54
let jwt ;
55
55
beforeEach ( async function ( ) {
@@ -61,15 +61,13 @@ describe("Logs", function () {
61
61
Sinon . restore ( ) ;
62
62
} ) ;
63
63
64
- it ( "Should return an object with status 500 and an error message" , async function ( ) {
64
+ it ( "Should return an Internal server error message" , async function ( ) {
65
65
addLogsStub = Sinon . stub ( logsQuery , "fetchLogs" ) ;
66
66
addLogsStub . throws ( new Error ( INTERNAL_SERVER_ERROR ) ) ;
67
67
68
68
addUser ( userToBeMadeMember ) . then ( ( ) => {
69
- const res = chai . request ( app ) . get ( "/logs/archive -details" ) . set ( "cookie" , `${ cookieName } =${ jwt } ` ) . send ( ) ;
69
+ const res = chai . request ( app ) . get ( "/logs/archived -details" ) . set ( "cookie" , `${ cookieName } =${ jwt } ` ) . send ( ) ;
70
70
71
- // expect(res).to.have.status(500);
72
- // expect(res.body).to.have.property("message").that.is.a("string");
73
71
expect ( res . body . message ) . to . equal ( INTERNAL_SERVER_ERROR ) ;
74
72
} ) ;
75
73
} ) ;
@@ -92,13 +90,13 @@ describe("Logs", function () {
92
90
expect ( data [ 0 ] ) . to . have . property ( "timestamp" ) . that . is . an ( "object" ) ;
93
91
expect ( data [ 0 ] . timestamp ) . to . have . property ( "_seconds" ) . that . is . a ( "number" ) ;
94
92
expect ( data [ 0 ] . timestamp ) . to . have . property ( "_nanoseconds" ) . that . is . a ( "number" ) ;
95
- expect ( data [ 0 ] . meta ) . to . have . property ( "username" ) . that . is . a ( "string" ) ;
93
+ expect ( data [ 0 ] . body . archived_user ) . to . have . property ( "username" ) . that . is . a ( "string" ) ;
96
94
expect ( data [ 0 ] . body ) . to . have . property ( "reason" ) . that . is . a ( "string" ) ;
97
95
} ) ;
98
- it ( "Should fetch all archived logs for given username " , async function ( ) {
96
+ it ( "Should fetch all archived logs for given user_id " , async function ( ) {
99
97
const { type, meta, body } = logsData . archivedUserDetailsModal [ 0 ] ;
100
98
const query = {
101
- userId : meta . userId ,
99
+ userId : body . archived_user . user_id ,
102
100
} ;
103
101
await logsQuery . addLog ( type , meta , body ) ;
104
102
const data = await logsQuery . fetchLogs ( query , type ) ;
@@ -107,7 +105,6 @@ describe("Logs", function () {
107
105
expect ( data [ 0 ] ) . to . have . property ( "timestamp" ) . that . is . an ( "object" ) ;
108
106
expect ( data [ 0 ] . timestamp ) . to . have . property ( "_seconds" ) . that . is . a ( "number" ) ;
109
107
expect ( data [ 0 ] . timestamp ) . to . have . property ( "_nanoseconds" ) . that . is . a ( "number" ) ;
110
- expect ( data [ 0 ] . meta ) . to . have . property ( "username" ) . that . is . a ( "string" ) ;
111
108
expect ( data [ 0 ] . body ) . to . have . property ( "reason" ) . that . is . a ( "string" ) ;
112
109
} ) ;
113
110
it ( "Should throw response status 404, if username is incorrect in the query" , async function ( ) {
@@ -117,7 +114,7 @@ describe("Logs", function () {
117
114
} ;
118
115
await logsQuery . addLog ( type , meta , body ) ;
119
116
const data = await logsQuery . fetchLogs ( query , type ) ;
120
- const response = await chai . request ( app ) . get ( `/logs/${ type } /${ meta . username } ` ) ;
117
+ const response = await chai . request ( app ) . get ( `/logs/${ type } /${ query } ` ) ;
121
118
122
119
expect ( data ) . to . be . an ( "array" ) . with . lengthOf ( 0 ) ;
123
120
expect ( response ) . to . have . status ( 404 ) ;
0 commit comments