-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(view comments): add view comments
- add view comments functionality - add view comments test - add swagger documentation of the feature [Starts #170766760]
- Loading branch information
1 parent
a3d6dde
commit f5a48ff
Showing
6 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import chai from 'chai'; | ||
import chaiHttp from 'chai-http'; | ||
import app from '../../app'; | ||
import { loggedInToken, userWithNoTripToken } from '../fixtures/users.fixture'; | ||
import { createTrip } from '../fixtures/trip.fixture'; | ||
import { badRequest } from '../fixtures/comments.fixture'; | ||
|
||
chai.should(); | ||
chai.use(chaiHttp); | ||
|
||
describe('/Get view comments posted on trips requests', () => { | ||
let trip; | ||
before(async () => { | ||
trip = await createTrip(); | ||
}); | ||
it('Should get comments posted on trip requests', (done) => { | ||
chai.request(app) | ||
.get(`/api/trips/request/${trip.id}/comments?page=1&limit=1`) | ||
.set('Authorization', loggedInToken) | ||
.end((err, res) => { | ||
res.body.should.be.an('object'); | ||
res.status.should.be.equal(200); | ||
res.body.data.should.have.property('pageMeta'); | ||
res.body.data.should.have.property('rows'); | ||
res.body.data.rows.should.be.an('array'); | ||
res.body.data.rows[0].should.have.property('id'); | ||
res.body.data.rows[0].should.have.property('userId'); | ||
res.body.data.rows[0].should.have.property('subjectId'); | ||
res.body.data.rows[0].should.have.property('subjectType'); | ||
res.body.data.rows[0].should.have.property('comment'); | ||
res.body.data.rows[0].should.have.property('createdAt'); | ||
res.body.data.rows[0].should.have.property('updatedAt'); | ||
res.body.should.have.property('message').equal('List all comments'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Should not allow invalid parameters passed in the route', (done) => { | ||
chai.request(app) | ||
.get(`/api/trips/request/${badRequest}/comments?page=1&limit=1`) | ||
.set('Authorization', loggedInToken) | ||
.end((err, res) => { | ||
res.body.should.be.an('object'); | ||
res.status.should.be.equal(400); | ||
res.body.should.have.property('message'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Should not show requested trip comments when no comment found or does not belong to the trip', (done) => { | ||
chai.request(app) | ||
.get(`/api/trips/request/${trip.id}/comments?page=1&limit=1`) | ||
.set('Authorization', userWithNoTripToken) | ||
.end((err, res) => { | ||
res.body.should.be.an('object'); | ||
res.status.should.be.equal(404); | ||
res.body.should.have.property('message').equal('Comments not found or does not belong to this trip'); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters