mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 10:11:40 -05:00
39 lines
806 B
TypeScript
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);
|
|
});
|