-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c57facf
commit f22b7c3
Showing
6 changed files
with
84 additions
and
4 deletions.
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,40 @@ | ||
// During the test the env variable is set to test | ||
process.env.NODE_ENV = 'test'; | ||
|
||
// Require the dev-dependencies | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const mock = require('../mock'); | ||
|
||
// Start the server | ||
const server = require('../../bin/www'); | ||
|
||
const should = chai.should(); // eslint-disable-line no-unused-vars | ||
|
||
chai.use(chaiHttp); | ||
|
||
describe('DELETE /api/user/:id', () => { | ||
let testUser; | ||
before(async () => { | ||
testUser = await mock.user(); | ||
}); | ||
|
||
it('Returns 200 and expected data', (done) => { | ||
chai.request(server) | ||
.delete(`/api/user/${testUser.id}`) | ||
.end((err, res) => { | ||
res.should.have.status(200); | ||
res.body.should.be.eq(1) | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Returns 404 for unknown ID', (done) => { | ||
chai.request(server) | ||
.delete('/api/user/unknownId') | ||
.end((err, res) => { | ||
res.should.have.status(404); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// During the test the env variable is set to test | ||
process.env.NODE_ENV = 'test'; | ||
|
||
// Require the dev-dependencies | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const mock = require('../mock'); | ||
|
||
// Start the server | ||
const server = require('../../bin/www'); | ||
|
||
const should = chai.should(); // eslint-disable-line no-unused-vars | ||
|
||
chai.use(chaiHttp); | ||
|
||
describe('GET /api/user/:id', () => { | ||
let testUser; | ||
before(async () => { | ||
testUser = await mock.user(); | ||
}); | ||
|
||
it('Returns 200 and expected data', (done) => { | ||
chai.request(server) | ||
.get(`/api/user/${testUser.id}`) | ||
.end((err, res) => { | ||
res.should.have.status(200); | ||
res.body.id.should.be.eq(testUser.id); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Returns 404 for unknown ID', (done) => { | ||
chai.request(server) | ||
.get('/api/user/unknownId') | ||
.end((err, res) => { | ||
res.should.have.status(404); | ||
done(); | ||
}); | ||
}); | ||
}); |