Last active
March 20, 2019 01:23
-
-
Save NedyUdombat/1f1ed4a0e22d35f2246b558c16fc9a56 to your computer and use it in GitHub Desktop.
Sample Test
This file contains hidden or 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
import chai from 'chai'; | |
import chaiHttp from 'chai-http'; | |
import app from '../server'; | |
// configure chai to use expect | |
chai.use(chaiHttp); | |
const { expect } = chai; | |
describe('Authentication tests', () => { | |
context('POST /', () => { | |
/* | |
** Testing Account Logout | |
*/ | |
it('/api/v1/auth/logout should respond with status code 200 and log user out', (done) => { | |
chai.request(app) | |
.post('/api/v1/auth/logout') | |
.set('x-access-token', authTokenAdmin) | |
.end((err, res) => { | |
expect(res.status).to.equal(200); | |
expect(res.body).to.be.a('object'); | |
expect(res.body.auth).eql(false); | |
expect(res.body.token).eql(null); | |
done(); | |
}); | |
}); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Equally, I think that's also the essence of using done() at the end of each test. It signifies the end of the test. One thing I think about though is putting the done() call into the afterEach hook so one doesn't have to do it at the end of each test.