apollo-server/packages/apollo-server-hapi/src/hapiApollo.test.ts
Laurin Quast df51fd90da Setup prettier (#724)
* Setup prettier and precommit hooks

* Format code with prettier

* Use husky because it works...

* Move prettier config to .prettierrc file

* Implement fixing markdown file formatting when running lint-fix script

* Format markdown files

* Add .json file formatting

* Fixes json file formatting

* Add pretteir linting step

* Remove tslint

* Use gitignore for prettier

* Fix linting errors

* Ignore submodule folder
2018-01-08 15:08:01 -08:00

48 lines
1,008 B
TypeScript

import * as hapi from 'hapi';
import { graphqlHapi, graphiqlHapi } from './hapiApollo';
import 'mocha';
import testSuite, {
schema as Schema,
CreateAppOptions,
} from 'apollo-server-integration-testsuite';
async function createApp(options: CreateAppOptions) {
const server = new hapi.Server({
host: 'localhost',
port: 8000,
});
await server.register({
plugin: graphqlHapi,
options: {
graphqlOptions: (options && options.graphqlOptions) || { schema: Schema },
path: '/graphql',
},
});
await server.register({
plugin: graphiqlHapi,
options: {
path: '/graphiql',
graphiqlOptions: (options && options.graphiqlOptions) || {
endpointURL: '/graphql',
},
},
});
await server.start();
return server.listener;
}
async function destroyApp(app) {
if (!app || !app.close) {
return;
}
await new Promise(resolve => app.close(resolve));
}
describe('integration:Hapi', () => {
testSuite(createApp, destroyApp);
});