1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-26 20:00:05 +02:00
copilot/packages/portal-api/test/index.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-04-28 00:59:03 +03:00
'use strict';
const Code = require('code');
const Hapi = require('hapi');
const Lab = require('lab');
const PortalApi = require('../');
// Test shortcuts
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const expect = Code.expect;
2017-05-02 01:28:03 +03:00
const internals = {
options: { data: { test: true, name: 'test' } }
};
internals.register = { register: PortalApi, options: internals.options };
2017-04-28 00:59:03 +03:00
describe('portal-api plugin', () => {
it('can be registered with hapi', (done) => {
const server = new Hapi.Server();
server.connection();
2017-05-02 01:28:03 +03:00
server.register(internals.register, (err) => {
2017-04-28 00:59:03 +03:00
expect(err).to.not.exist();
done();
});
});
});
2017-05-23 00:25:21 +03:00
describe('graphql', () => {
2017-04-28 00:59:03 +03:00
it('route exists', (done) => {
const server = new Hapi.Server();
server.connection();
2017-05-02 01:28:03 +03:00
server.register(internals.register, (err) => {
2017-04-28 00:59:03 +03:00
expect(err).to.not.exist();
2017-05-23 00:25:21 +03:00
const url = '/graphql?query=%7B%0A%20%20deploymentGroups(name%3A%22hi%22%2C%20slug%3A%20%22hi%22)%20%7B%0A%20%20%20%20id%0A%20%20%7D%0A%7D';
2017-04-28 00:59:03 +03:00
server.inject({ method: 'GET', url }, (res) => {
expect(res.statusCode).to.equal(200);
const result = JSON.parse(res.result);
expect(result.data).to.exist();
2017-05-23 00:25:21 +03:00
expect(result.data.deploymentGroups).to.be.null();
2017-04-28 00:59:03 +03:00
done();
});
});
});
});