-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathhapiApollo.test.ts
39 lines (31 loc) · 970 Bytes
/
hapiApollo.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { ApolloServer } from '../ApolloServer';
import { Config } from 'apollo-server-core';
import testSuite, {
schema as Schema,
CreateAppOptions,
NODE_MAJOR_VERSION,
} from 'apollo-server-integration-testsuite';
// NODE: Intentionally skip on Node.js < 8 since Hapi 17 doesn't support less
(NODE_MAJOR_VERSION < 8 ? describe.skip : describe)('integration:Hapi', () => {
async function createApp(options: CreateAppOptions = {}) {
const { Server } = require('hapi');
const app: import('hapi').Server = new Server({
host: 'localhost',
});
const server = new ApolloServer(
(options.graphqlOptions as Config) || { schema: Schema },
);
await server.applyMiddleware({
app,
});
await app.start();
return app.listener;
}
async function destroyApp(app) {
if (!app || !app.close) {
return;
}
await new Promise(resolve => app.close(resolve));
}
testSuite(createApp, destroyApp);
});