apollo-server/packages/graphql-server-hapi/src/hapiApollo.test.ts

39 lines
839 B
TypeScript
Raw Normal View History

2016-07-05 17:25:18 -07:00
import * as hapi from 'hapi';
import { graphqlHapi, graphiqlHapi, HapiPluginOptions } from './hapiApollo';
import 'mocha';
2016-07-05 17:25:18 -07:00
import testSuite, { Schema } from 'graphql-server-integration-testsuite';
2016-07-05 17:25:18 -07:00
function createApp(createOptions: HapiPluginOptions) {
2016-07-05 17:25:18 -07:00
const server = new hapi.Server();
server.connection({
host: 'localhost',
port: 8000,
});
server.register({
register: graphqlHapi,
options: {
2016-10-22 23:52:32 -07:00
graphqlOptions: createOptions ? createOptions.graphqlOptions : { schema: Schema },
path: '/graphql',
},
2016-07-05 17:25:18 -07:00
});
2016-07-06 07:05:59 -07:00
server.register({
register: graphiqlHapi,
options: {
path: '/graphiql',
graphiqlOptions: {
endpointURL: '/graphql',
},
},
2016-07-06 07:05:59 -07:00
});
return server.listener;
2016-07-05 17:25:18 -07:00
}
describe('integration:Hapi', () => {
testSuite(createApp);
});