Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created March 18, 2016 16:44
Show Gist options
  • Save jhyland87/dc12978ad50c03e8100f to your computer and use it in GitHub Desktop.
Save jhyland87/dc12978ad50c03e8100f to your computer and use it in GitHub Desktop.
'use strict'
// Tools
const _ = require( 'lodash' )
const appRoot = require( 'app-root-path' )
const Util = require( 'util' )
// Unit test related
const Code = require( 'code' )
const Lab = require( 'lab' )
const lab = exports.lab = Lab.script()
const suite = lab.suite
const it = lab.test
const before = lab.before
const describe = lab.experiment
const after = lab.after
const expect = Code.expect
const beforeEach = lab.beforeEach
const afterEach = lab.afterEach
// Hapi related
const Hapi = require( 'hapi' )
const Glue = require( 'glue' )
before( done => {
done()
})
describe('Invia', () => {
describe('initiation', () => {
it('should fail when no `routeDir` is defined and the default routes path (`./routes`) is not valid', done => {
const server = new Hapi.Server();
server.connection();
server.register([ {
register: require('../')
} ], err => {
expect( err ).to.exist()
server.stop( stopErr => done( stopErr ))
})
})
it('should fail with an incorrect `routeDir` value', done => {
const server = new Hapi.Server();
server.connection();
server.register([ {
register: require('../'),
options: {
routeDir: './test/test_routes-fake'
}
} ], err => {
expect( err ).to.exist()
server.stop( stopErr => done( stopErr ))
})
})
it('should load the routes successfully with all valid settings', done => {
const server = new Hapi.Server();
const connection = server.connection();
server.register([ {
register: require('../'),
options: {
routeDir: './test/test_routes'
}
},{
register: require('blipp')
} ], err => {
expect( err ).to.not.exist()
server.start( err => {
expect( err ).to.not.exist()
console.log( Util.inspect( server.table(), true, null ))
server.stop( stopErr => done( stopErr ))
})
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment