| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 'use strict'
-
- const test = require('ava')
- const Hapi = require('@hapi/hapi')
- const Schwifty = require('@hapipal/schwifty')
- const Schmervice = require('@hapipal/schmervice')
-
- const MatchQueService = require('../lib/services/matchqueue')
- const MatchQueModel = require('../lib/models/matchqueue')
-
- test('path / should return ok on GET', async t => {
- const server = Hapi.server()
-
- await server.register({
- plugin: Schwifty,
- options: {
- knex: {
- client: 'mysql',
- useNullAsDefault: true,
- connection: {
- host: process.env.DB_HOST,
- user: process.env.DB_USER,
- password: process.env.DB_ROOT_PASSWORD,
- database: process.env.DB_NAME,
- },
- },
- },
- })
-
- await server.register(Schmervice)
- await server.registerModel(MatchQueModel)
- await server.registerService(MatchQueService)
-
- // I can't quite wrap my head around why this wouldn't at least reference this.server.models()
- // returns TypeError {
- // message: 'Cannot read properties of undefined (reading \ 'models\')'
- // }
-
- const matchQueService = new MatchQueService()
- const potentials = await matchQueService.getQueue()
- console.log(potentials)
- t.is(payload, '{"test":"hello, world"}')
- t.is(statusCode, 200)
- })
|