@@ -109,29 +109,27 @@ describe('Integration tests for: /api/home', function() {
109109 . get ( '/api/home' )
110110 . set ( 'Authorization' , `Bearer ${ jwtToken } ` )
111111 . then ( res => {
112+ console . log ( "The body:" , res . body [ 0 ] . sets ) ;
112113 expect ( res ) . to . have . status ( HTTP_STATUS_CODES . OK ) ;
113114 expect ( res ) . to . be . json ;
114115 expect ( res . body ) . to . be . a ( 'array' ) ;
115116 expect ( res . body ) . to . have . lengthOf . at . least ( 1 ) ;
116- console . log ( "The body:" , res . body [ 0 ] . sets ) ;
117- const workout = res . body [ 0 ] . sets ;
118117
119- expect ( workout ) . to . include . keys ( 'user' , 'exercise' , 'set' , 'reps' ) ;
120- // expect(workout.user).to.be.a('object');
121- // expect(workout.user).to.include.keys('name', 'email', 'username');
122- // expect(workout.user).to.nested.include({
123- // id: testUser.id,
124- // username: testUser.username,
125- // email: testUser.email,
126- // name: testUser.name
127- // });
118+ const workout = res . body [ 0 ] ;
119+ console . log ( "User workout:" , workout )
120+
121+ expect ( workout ) . to . include . keys ( 'user' , 'sets' ) ;
122+ expect ( workout . sets ) . to . include . keys ( 'exercise' , 'set' , 'reps' )
123+ expect ( workout . user ) . to . be . a ( 'string' ) ;
124+
128125 } ) ;
129126 } ) ;
130127
131128 it ( 'Should return a specific workout' , function ( ) {
132129 let foundWorkout ;
133130 return Workout . find ( )
134131 . then ( workouts => {
132+
135133 expect ( workouts ) . to . be . a ( 'array' ) ;
136134 expect ( workouts ) . to . have . lengthOf . at . least ( 1 ) ;
137135 foundWorkout = workouts [ 0 ] ;
@@ -141,10 +139,12 @@ describe('Integration tests for: /api/home', function() {
141139 . set ( 'Authorization' , `Bearer ${ jwtToken } ` ) ;
142140 } )
143141 . then ( res => {
142+
144143 expect ( res ) . to . have . status ( HTTP_STATUS_CODES . OK ) ;
145144 expect ( res ) . to . be . json ;
146- expect ( res . body ) . to . be . a ( 'object' ) ;
147- expect ( res . body ) . to . include . keys ( 'user' , 'exercise' , 'set' , 'reps' ) ;
145+ // expect(res.body).to.be.a('object');
146+ expect ( res . body ) . to . include . keys ( 'user' , 'sets' ) ;
147+ expect ( res . body . sets ) . to . include . keys ( 'exercise' , 'set' , 'reps' ) ;
148148
149149 } ) ;
150150 } ) ;
@@ -183,11 +183,6 @@ describe('Integration tests for: /api/home', function() {
183183 }
184184
185185 function createFakerWorkout ( ) {
186- return {
187- exercise : faker . lorem . word ( ) ,
188- set : faker . random . number ( ) ,
189- reps : faker . random . number ( ) ,
190-
191- } ;
186+ return { sets :{ exercise : faker . lorem . word ( ) , set : faker . random . number ( ) , reps : faker . random . number ( ) } } ;
192187 }
193188} ) ;
0 commit comments