experiment('Target unit tests', () => { const dataRetriever = new DataRetrievalRouter(); test('should apply (partial match)', (done) => { const invalidTarget = []; Rbac.evaluateTarget(invalidTarget, dataRetriever, (err, applies) => { expect(err).to.exist(); done(); }); }); });
experiment('model utils', () => { test('formats order numbers correctly', (done) => { expect(util.formatOrderId(1)).to.equal('0001') expect(util.formatOrderId(10)).to.equal('0010') expect(util.formatOrderId(9999)).to.equal('9999') done() }) test('estimated arrival generates a date in the future', (done) => { expect(util.estimatedArrival()).to.be.a.date() expect(util.estimatedArrival() - Date.now()).to.be.greaterThan(0) done() }) })
experiment('getting started with hapi testing', () => { test('test if the route returns JSON by default', done => { const options = { method: 'GET', url: '/' } server.inject(options, response => { const payload = JSON.parse(response.payload || '{}') Code.expect(response.statusCode).to.equal(200) Code.expect(payload.name).to.equal('Marcus') Code.expect(payload.isDeveloper).to.equal(true) done() }) }) })
experiment('Base Model', () => { test('should not work without a db', (done) => { expect(() => new Base()).to.throw() done() }) test('should work with a db', async () => { const db = await createDb() expect(() => new Base(db)).to.not.throw() }) })
experiment('Target unit tests (AND with field agains field matching)', () => {
experiment('Couriers', () => { let db let couriers
experiment('hapi-tutorials run actions before and after tests', () => {
experiment('Target unit tests (AND)', () => {
experiment('Models:Order', () => { let orders = null let db
experiment('Generic tests, with RBAC plugin configured', () => {
experiment('hapi-tutorials base plugin', () => { test('test if the plugin returns JSON by default', done => { const query = Qs.stringify({ name: 'Marcus' }) const page = 1 const options = { url: `/inject-data/${page}?${query}`, method: 'POST', payload: { isGeek: false }, headers: { 'X-Testing-Header': 'Testing-123' } } server.inject(options, response => { const payload = JSON.parse(response.payload || '{}') Code.expect(response.statusCode).to.equal(200) Code.expect(payload.name).to.equal('Marcus') Code.expect(payload.isGeek).to.equal(false) Code.expect(parseInt(payload.page)).to.equal(page) Code.expect(payload['x-testing-header']).to.equal('Testing-123') done() }) }) })
experiment('Rule unit tests', () => {
experiment('Rule unit tests (permit)', () => {
experiment('Target unit tests (AND with RegExp)', () => {
experiment('Target unit tests (OR)', () => {