apollo-server/packages/apollo-server-hapi/src/hapiApollo.test.ts
David Glasser eb0ae81cfa Update integration test suite to test ApolloServer
Fix some connect bugs.
2018-06-13 15:27:44 -07:00

39 lines
806 B
TypeScript

import hapi from 'hapi';
import { registerServer, ApolloServer } from './ApolloServer';
import { Config } from 'apollo-server-core';
import 'mocha';
import testSuite, {
schema as Schema,
CreateAppOptions,
} from 'apollo-server-integration-testsuite';
async function createApp(options: CreateAppOptions = {}) {
const app = new hapi.Server({
host: 'localhost',
port: 8000,
});
const server = new ApolloServer(
(options.graphqlOptions as Config) || { schema: Schema },
);
await registerServer({
server,
app,
});
await app.start();
return app.listener;
}
async function destroyApp(app) {
if (!app || !app.close) {
return;
}
await new Promise(resolve => app.close(resolve));
}
describe('integration:Hapi', () => {
testSuite(createApp, destroyApp);
});