You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
caption: 'Han Market is a prominent attraction in Da Nang, having served the local population since the French occupation in the early 20th century. Located at the grand intersection of Tran Phu Street, Bach Dang Street, Hung Vuong Street and Tran Hung Dao Street, visitors can find hundreds of stalls selling just about everything from local produce and coffee beans to T-shirts, jewellery, and accessories.',
198
+
location: 'Han Market',
199
+
user: user,
200
+
category: 'Markets'
201
+
})
202
+
.then(gemData=>{
203
+
returngem=gemData
204
+
})
205
+
.then(()=>done())
206
+
.catch(done)
207
+
})
208
+
209
+
it('should return a 200 response',done=>{
210
+
api
211
+
.get(`/api/gems/${gem._id}`)
212
+
.set('Accept','application/json')
213
+
.set('Authorization','Bearer '+token)
214
+
.expect(200,done)
215
+
})
216
+
217
+
it('should respond with a JSON object',done=>{
218
+
api
219
+
.get(`/api/gems/${gem._id}`)
220
+
.set('Accept','application/json')
221
+
.set('Authorization','Bearer '+token)
222
+
.end((err,res)=>{
223
+
expect(res.header['content-type'])
224
+
.to.be.eq('application/json; charset=utf-8')
225
+
done()
226
+
})
227
+
})
228
+
229
+
it('should return a gem object',done=>{
230
+
api
231
+
.get(`/api/gems/${gem._id}`)
232
+
.set('Accept','application/json')
233
+
.set('Authorization','Bearer '+token)
234
+
.end((err,res)=>{
235
+
expect(res.body)
236
+
.and.be.an('object')
237
+
.and.have.all.keys([
238
+
'__v',
239
+
'_id',
240
+
'image',
241
+
'caption',
242
+
'location',
243
+
'user',
244
+
'category',
245
+
'comments',
246
+
'createdAt',
247
+
'id',
248
+
'likeCount',
249
+
'updatedAt'
250
+
])
251
+
done()
252
+
})
253
+
})
254
+
255
+
it('gem object should have properities: _id, title, image, comments',done=>{
256
+
api
257
+
.get(`/api/gems/${gem._id}`)
258
+
.set('Accept','application/json')
259
+
.set('Authorization','Bearer '+token)
260
+
.end((err,res)=>{
261
+
constgem=res.body
262
+
263
+
expect(gem)
264
+
.to.have.property('_id')
265
+
.and.to.be.a('string')
191
266
267
+
expect(gem)
268
+
.to.have.property('image')
269
+
.and.to.be.a('string')
270
+
271
+
expect(gem)
272
+
.to.have.property('caption')
273
+
.and.to.be.a('string')
274
+
275
+
276
+
expect(gem)
277
+
.to.have.property('location')
278
+
.and.to.be.a('string')
279
+
280
+
expect(gem)
281
+
.to.have.property('category')
282
+
.and.to.be.a('string')
192
283
284
+
done()
285
+
})
286
+
})
287
+
})
288
+
289
+
describe('POST /api/gems - Create Gem API Endpoint',()=>{
0 commit comments