Skip to content

Commit

Permalink
test(hapi): improve Hapi plugin test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelyke authored and Peter Marton committed Jul 27, 2015
1 parent e826ad3 commit 1be58ad
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/hapi/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var expect = require('chai').expect;
var Hapi = require('hapi');

describe('graffiti hapi', function() {

Expand Down Expand Up @@ -27,4 +28,45 @@ describe('graffiti hapi', function() {

});

describe('returns with proper results', function(done) {

var server = new Hapi.Server();
server.connection({ port: 3000 });

var result = {
users: [1, 2, 3]
};

server.register({
register: hapi.create({
graphql: function() {
return Promise.resolve(result);
}
}),
options: {
models: [],
adapter: {
getSchema: function() {}
}
}
}, {
routes: {
prefix: '/graphql'
}
}, function(err) {
if (err) {
return done(err);
}

server.inject({
method: 'GET',
url: '/graphql?q={__type}'
}, function(res) {
expect(JSON.parse(res.payload)).to.eql(result);
done();
});
});

});

});

0 comments on commit 1be58ad

Please sign in to comment.