|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+'use strict'
|
|
|
2
|
+
|
|
|
3
|
+const test = require('ava')
|
|
|
4
|
+const Hapi = require('@hapi/hapi')
|
|
|
5
|
+const Schwifty = require('@hapipal/schwifty')
|
|
|
6
|
+const Schmervice = require('@hapipal/schmervice')
|
|
|
7
|
+
|
|
|
8
|
+const MatchQueService = require('../lib/services/matchqueue')
|
|
|
9
|
+const MatchQueModel = require('../lib/models/matchqueue')
|
|
|
10
|
+
|
|
|
11
|
+test('path / should return ok on GET', async t => {
|
|
|
12
|
+ const server = Hapi.server()
|
|
|
13
|
+
|
|
|
14
|
+ await server.register({
|
|
|
15
|
+ plugin: Schwifty,
|
|
|
16
|
+ options: {
|
|
|
17
|
+ knex: {
|
|
|
18
|
+ client: 'mysql',
|
|
|
19
|
+ useNullAsDefault: true,
|
|
|
20
|
+ connection: {
|
|
|
21
|
+ host: process.env.DB_HOST,
|
|
|
22
|
+ user: process.env.DB_USER,
|
|
|
23
|
+ password: process.env.DB_ROOT_PASSWORD,
|
|
|
24
|
+ database: process.env.DB_NAME,
|
|
|
25
|
+ },
|
|
|
26
|
+ },
|
|
|
27
|
+ },
|
|
|
28
|
+ })
|
|
|
29
|
+
|
|
|
30
|
+ await server.register(Schmervice)
|
|
|
31
|
+ await server.registerModel(MatchQueModel)
|
|
|
32
|
+ await server.registerService(MatchQueService)
|
|
|
33
|
+
|
|
|
34
|
+ // I can't quite wrap my head around why this wouldn't at least reference this.server.models()
|
|
|
35
|
+ // returns TypeError {
|
|
|
36
|
+ // message: 'Cannot read properties of undefined (reading \ 'models\')'
|
|
|
37
|
+ // }
|
|
|
38
|
+
|
|
|
39
|
+ const matchQueService = new MatchQueService()
|
|
|
40
|
+ const potentials = await matchQueService.getQueue()
|
|
|
41
|
+ console.log(potentials)
|
|
|
42
|
+ t.is(payload, '{"test":"hello, world"}')
|
|
|
43
|
+ t.is(statusCode, 200)
|
|
|
44
|
+})
|