2016-07-05 17:25:18 -07:00
|
|
|
import * as hapi from 'hapi';
|
2016-07-06 07:05:59 -07:00
|
|
|
import { ApolloHAPI, GraphiQLHAPI } from './hapiApollo';
|
2016-07-05 17:25:18 -07:00
|
|
|
|
|
|
|
import testSuite, { Schema, CreateAppOptions } from './integrations.test';
|
|
|
|
|
|
|
|
function createApp(options: CreateAppOptions = {}) {
|
|
|
|
const server = new hapi.Server();
|
|
|
|
|
|
|
|
server.connection({
|
|
|
|
host: 'localhost',
|
|
|
|
port: 8000,
|
|
|
|
});
|
|
|
|
|
2016-07-07 22:36:44 -07:00
|
|
|
options.apolloOptions = options.apolloOptions || { schema: Schema };
|
|
|
|
|
2016-07-05 17:25:18 -07:00
|
|
|
server.register({
|
2016-07-06 07:05:59 -07:00
|
|
|
register: new ApolloHAPI(),
|
2016-07-07 22:36:44 -07:00
|
|
|
options: options.apolloOptions,
|
2016-07-05 17:25:18 -07:00
|
|
|
routes: { prefix: '/graphql' },
|
|
|
|
});
|
|
|
|
|
2016-07-06 07:05:59 -07:00
|
|
|
server.register({
|
|
|
|
register: new GraphiQLHAPI(),
|
|
|
|
options: { endpointURL: '/graphql' },
|
2016-07-16 07:12:08 -07:00
|
|
|
routes: { prefix: '/graphiql' },
|
2016-07-06 07:05:59 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
return server.listener;
|
2016-07-05 17:25:18 -07:00
|
|
|
}
|
|
|
|
|
2016-07-16 07:31:14 -07:00
|
|
|
describe('integration:HAPI', () => {
|
2016-07-07 08:46:10 -07:00
|
|
|
testSuite(createApp);
|
|
|
|
});
|