node-go/packages/play-node-go/server/test/spec.js

51 lines
1 KiB
JavaScript
Raw Normal View History

2020-01-08 21:25:28 +00:00
process.env.NODE_ENV = 'test';
const chai = require('chai');
const chaiHttp = require('chai-http');
2020-01-15 07:09:01 +00:00
const knex = require('../data/db');
2020-01-08 21:25:28 +00:00
const server = require('../server');
2020-01-08 21:25:28 +00:00
const should = chai.should();
const authSignupSpec = require('./auth.signup.spec');
const authLoginSpec = require('./auth.login.spec');
2020-01-08 21:25:28 +00:00
chai.use(chaiHttp);
// ! to run tests from other testing modules
// import someTest from './endpoint/someTest';
const setupDb = () => {
beforeEach(done => {
knex.migrate.rollback(true)
.then(() => knex.migrate.latest())
.then(() => done());
});
2020-01-14 22:22:42 +00:00
afterEach(done => {
knex.migrate.rollback(true)
.then(() => done());
})
}
describe('Auth Routes', function() {
setupDb();
authSignupSpec(chai, knex, server);
authLoginSpec(chai, knex, server);
2020-01-15 07:09:01 +00:00
});
2020-01-08 21:25:28 +00:00
describe('API Routes', function() {
setupDb();
2020-01-15 07:09:01 +00:00
it('home should return 200 status', done => {
chai.request(server)
2020-01-15 07:09:01 +00:00
.get('/')
.end((err,res)=> {
if(err) done(err);
res.should.status(200);
done();
});
});
2020-01-08 21:25:28 +00:00
});