|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const Lab = require('@hapi/lab'); |
| 4 | +const { expect } = require('@hapi/code'); |
| 5 | +const Glue = require('@hapi/glue'); |
| 6 | +const { afterEach, beforeEach, describe, it } = exports.lab = Lab.script(); |
| 7 | +const Manifest = require('../config/manifest'); |
| 8 | + |
| 9 | +// Loaded by plugins/dbDevel_lowerings.js in NODE_ENV=test. This lowering's |
| 10 | +// fixture events are FISH/CORAL only, so filtering for ASNAP should be empty. |
| 11 | +const publicLowering4928ID = '6981f167212b348aed7fa9f5'; |
| 12 | +const missingEventValue = 'ASNAP'; |
| 13 | + |
| 14 | +const initStartedServer = async () => { |
| 15 | + |
| 16 | + const manifest = JSON.parse(JSON.stringify(Manifest)); |
| 17 | + manifest.server.port = 0; |
| 18 | + |
| 19 | + const server = await Glue.compose(manifest, { relativeTo: __dirname + '/..' }); |
| 20 | + await server.start(); |
| 21 | + |
| 22 | + return server; |
| 23 | +}; |
| 24 | + |
| 25 | +describe('GET /sealog-server/api/v1/events/bylowering/{id}', () => { |
| 26 | + let server; |
| 27 | + |
| 28 | + beforeEach(async () => { |
| 29 | + server = await initStartedServer(); |
| 30 | + }); |
| 31 | + |
| 32 | + afterEach(async () => { |
| 33 | + await server.stop(); |
| 34 | + }); |
| 35 | + |
| 36 | + it('responds with an empty array when the lowering exists but no events match', async () => { |
| 37 | + const res = await server.inject({ |
| 38 | + method: 'get', |
| 39 | + url: `/sealog-server/api/v1/events/bylowering/${publicLowering4928ID}?value=${missingEventValue}` |
| 40 | + }); |
| 41 | + |
| 42 | + expect(res.statusCode).to.equal(200); |
| 43 | + expect(res.result).to.equal([]); |
| 44 | + }); |
| 45 | +}); |
0 commit comments