node-go/server/test/spec.js

44 lines
940 B
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-18 00:32:40 +00:00
const apiIndexSpec = require('./api.index.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
2020-01-18 00:32:40 +00:00
apiIndexSpec(chai, knex, server)
2020-01-15 07:09:01 +00:00
2020-01-08 21:25:28 +00:00
});