@@ -26,7 +26,7 @@ const {
2626const expect = chai . expect ; // So we can do "expect" instead of always typing "chai.expect"
2727chai . use ( chaiHttp ) ; // implements chai http plugin
2828
29- describe ( 'Integration tests for: /api/note ' , function ( ) {
29+ describe ( 'Integration tests for: /api/workout ' , function ( ) {
3030 let testUser , jwtToken ;
3131
3232 // Mocha Hook: Runs before ALL the "it" test blocks.
@@ -75,11 +75,11 @@ describe('Integration tests for: /api/note', function() {
7575
7676 const seedData = [ ] ;
7777 for ( let i = 1 ; i <= 10 ; i ++ ) {
78- const newNote = createFakerNote ( ) ;
79- newNote . user = createdUser . id ;
80- seedData . push ( newNote ) ;
78+ const newWorkout = createFakerWorkout ( ) ;
79+ newWorkout . user = createdUser . id ;
80+ seedData . push ( newWorkout ) ;
8181 }
82- return Note . insertMany ( seedData )
82+ return Workout . insertMany ( seedData )
8383 . catch ( err => {
8484 console . error ( err ) ;
8585 throw new Error ( err ) ;
@@ -113,20 +113,20 @@ describe('Integration tests for: /api/note', function() {
113113 return stopServer ( ) ;
114114 } ) ;
115115
116- it ( 'Should return user notes ' , function ( ) {
116+ it ( 'Should return user workouts ' , function ( ) {
117117 return chai . request ( app )
118- . get ( '/api/note ' )
118+ . get ( '/api/workout ' )
119119 . set ( 'Authorization' , `Bearer ${ jwtToken } ` )
120120 . then ( res => {
121121 expect ( res ) . to . have . status ( HTTP_STATUS_CODES . OK ) ;
122122 expect ( res ) . to . be . json ;
123123 expect ( res . body ) . to . be . a ( 'array' ) ;
124124 expect ( res . body ) . to . have . lengthOf . at . least ( 1 ) ;
125- const note = res . body [ 0 ] ;
126- expect ( note ) . to . include . keys ( 'user' , 'title ' , 'content ' ) ;
127- expect ( note . user ) . to . be . a ( 'object' ) ;
128- expect ( note . user ) . to . include . keys ( 'name' , 'email' , 'username' ) ;
129- expect ( note . user ) . to . deep . include ( {
125+ const workout = res . body [ 0 ] ;
126+ expect ( workout ) . to . include . keys ( 'user' , 'exercise ' , 'set ' ) ;
127+ expect ( workout . user ) . to . be . a ( 'object' ) ;
128+ expect ( workout . user ) . to . include . keys ( 'name' , 'email' , 'username' ) ;
129+ expect ( workout . user ) . to . deep . include ( {
130130 id : testUser . id ,
131131 username : testUser . username ,
132132 email : testUser . email ,
@@ -135,16 +135,16 @@ describe('Integration tests for: /api/note', function() {
135135 } ) ;
136136 } ) ;
137137
138- it ( 'Should return a specific note ' , function ( ) {
139- let foundNote ;
138+ it ( 'Should return a specific workout ' , function ( ) {
139+ let foundWorkout ;
140140 return Workout . find ( )
141- . then ( notes => {
142- expect ( notes ) . to . be . a ( 'array' ) ;
143- expect ( notes ) . to . have . lengthOf . at . least ( 1 ) ;
141+ . then ( workouts => {
142+ expect ( workouts ) . to . be . a ( 'array' ) ;
143+ expect ( workouts ) . to . have . lengthOf . at . least ( 1 ) ;
144144 foundWorkout = workouts [ 0 ] ;
145145
146146 return chai . request ( app )
147- . get ( `/api/note /${ foundNote . id } ` )
147+ . get ( `/api/workout /${ foundWorkout . id } ` )
148148 . set ( 'Authorization' , `Bearer ${ jwtToken } ` ) ;
149149 } )
150150 . then ( res => {
@@ -153,61 +153,60 @@ describe('Integration tests for: /api/note', function() {
153153 expect ( res . body ) . to . be . a ( 'object' ) ;
154154 expect ( res . body ) . to . include . keys ( 'user' , 'title' , 'content' ) ;
155155 expect ( res . body ) . to . deep . include ( {
156- id : foundNote . id ,
157- title : foundNote . title ,
158- content : foundNote . content
156+ id : foundWorkout . id ,
157+ exercise : foundWorkout . exercise
158+
159159 } ) ;
160160 } ) ;
161161 } ) ;
162162
163- it ( 'Should update a specific note ' , function ( ) {
164- let noteToUpdate ;
165- const newNoteData = createFakerNote ( ) ;
166- return Note . find ( )
167- . then ( notes => {
168- expect ( notes ) . to . be . a ( 'array' ) ;
169- expect ( notes ) . to . have . lengthOf . at . least ( 1 ) ;
170- noteToUpdate = notes [ 0 ] ;
163+ it ( 'Should update a specific workout ' , function ( ) {
164+ let workoutToUpdate ;
165+ const newWorkoutData = createFakerWorkout ( ) ;
166+ return Workout . find ( )
167+ . then ( workouts => {
168+ expect ( workouts ) . to . be . a ( 'array' ) ;
169+ expect ( workouts ) . to . have . lengthOf . at . least ( 1 ) ;
170+ workoutToUpdate = workouts [ 0 ] ;
171171
172172 return chai . request ( app )
173- . put ( `/api/note /${ noteToUpdate . id } ` )
173+ . put ( `/api/workout /${ workoutToUpdate . id } ` )
174174 . set ( 'Authorization' , `Bearer ${ jwtToken } ` )
175- . send ( newNoteData ) ;
175+ . send ( newWorkoutData ) ;
176176 } )
177177 . then ( res => {
178178 expect ( res ) . to . have . status ( HTTP_STATUS_CODES . NO_CONTENT ) ;
179179
180- return Note . findById ( noteToUpdate . id ) ;
180+ return Workout . findById ( workoutToUpdate . id ) ;
181181 } )
182- . then ( note => {
183- expect ( note ) . to . be . a ( 'object' ) ;
184- expect ( note ) . to . deep . include ( {
185- id : noteToUpdate . id ,
186- title : newNoteData . title ,
187- content : newNoteData . content
182+ . then ( workout => {
183+ expect ( workout ) . to . be . a ( 'object' ) ;
184+ expect ( workout ) . to . deep . include ( {
185+ id : workoutToUpdate . id ,
186+ exercise : newWorkoutData . title ,
188187 } ) ;
189188 } ) ;
190189 } ) ;
191190
192- it ( 'Should delete a specific note ' , function ( ) {
193- let noteToDelete ;
194- return Note . find ( )
195- . then ( notes => {
196- expect ( notes ) . to . be . a ( 'array' ) ;
197- expect ( notes ) . to . have . lengthOf . at . least ( 1 ) ;
198- noteToDelete = notes [ 0 ] ;
191+ it ( 'Should delete a specific workout ' , function ( ) {
192+ let workoutToDelete ;
193+ return Workout . find ( )
194+ . then ( workouts => {
195+ expect ( workouts ) . to . be . a ( 'array' ) ;
196+ expect ( workouts ) . to . have . lengthOf . at . least ( 1 ) ;
197+ workoutToDelete = workouts [ 0 ] ;
199198
200199 return chai . request ( app )
201- . delete ( `/api/note /${ noteToDelete . id } ` )
200+ . delete ( `/api/workout /${ workoutToDelete . id } ` )
202201 . set ( 'Authorization' , `Bearer ${ jwtToken } ` ) ;
203202 } )
204203 . then ( res => {
205204 expect ( res ) . to . have . status ( HTTP_STATUS_CODES . NO_CONTENT ) ;
206205
207- return Note . findById ( noteToDelete . id ) ;
206+ return Workout . findById ( workoutToDelete . id ) ;
208207 } )
209- . then ( note => {
210- expect ( note ) . to . not . exist ;
208+ . then ( workout => {
209+ expect ( workout ) . to . not . exist ;
211210 } ) ;
212211 } ) ;
213212
@@ -220,10 +219,10 @@ describe('Integration tests for: /api/note', function() {
220219 } ;
221220 }
222221
223- function createFakerNote ( ) {
222+ function createFakerworkout ( ) {
224223 return {
225224 title : faker . lorem . sentence ( ) ,
226225 content : faker . lorem . paragraphs ( )
227226 } ;
228227 }
229- } ) ;
228+ } ) ;
0 commit comments