Skip to content

Instantly share code, notes, and snippets.

@rayriffy
Last active February 21, 2019 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayriffy/0ae1d58797ffa1389a5537cc023a9c44 to your computer and use it in GitHub Desktop.
Save rayriffy/0ae1d58797ffa1389a5537cc023a9c44 to your computer and use it in GitHub Desktop.
const chai = require('chai')
const chaiHttp = require('chai-http')
const {after, before, describe, it} = require('mocha')
const server = require('../build/main').default
chai.use(chaiHttp)
chai.should()
describe('Testing unit 1', () => {
before(done => {
// Do something here before test
done()
})
describe('GET /', () => {
it('it should have message OK', done => {
chai
.request(server)
.get('/')
.end((e, res) => {
res.should.have.status(200)
res.body.should.have.property('message').eql('OK')
done()
})
})
})
describe('POST /', () => {
it('it should have message OK with POST', done => {
chai
.request(server)
.post('/')
.set('Authorization', 'WHATTTTT')
.send({
data: 'OK',
})
.end((e, res) => {
res.should.have.status(200)
res.body.should.have.property('message').eql('OK with POST')
done()
})
})
})
after(done => {
// Do something here after test
done()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment