From 58a7078eb36515aab29ea68a8168c6d919fc4f67 Mon Sep 17 00:00:00 2001 From: Christopher Van Date: Wed, 14 Jan 2015 02:25:30 -0800 Subject: [PATCH] add test for `GET /games/{idOrSlug}` hapi endpoint (fixes #302) --- test/api/controllers/game.js | 54 +++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/test/api/controllers/game.js b/test/api/controllers/game.js index 2b829fc..cb56928 100644 --- a/test/api/controllers/game.js +++ b/test/api/controllers/game.js @@ -128,7 +128,7 @@ lab.experiment('game creation', function () { }); -lab.experiment('games list', function () { +lab.experiment('game list', function () { lab.afterEach(function (done) { @@ -184,3 +184,55 @@ lab.experiment('games list', function () { }); }); }); + + +lab.experiment('game detail', function () { + + + lab.afterEach(function (done) { + + db.query('TRUNCATE games', done); + }); + + + lab.test('returns a 404 when game does not exist', function (done) { + + req = { + method: 'GET', + url: '/games/no-flex-zone' + }; + + server.inject(req, function (res) { + + Code.expect(res.statusCode).to.equal(404); + + done(); + }); + }); + + + lab.test('returns an object when game exists', function (done) { + + submitGame().then(function (prevReq) { + + req = { + method: 'GET', + url: '/games/no-flex-zone' + }; + + server.inject(req, function (res) { + + Code.expect(res.result).to.deep.equal({ + name: prevReq.payload.name, + slug: prevReq.payload.slug, + game_url: prevReq.payload.game_url, + description: prevReq.payload.description + }); + + Code.expect(res.statusCode).to.equal(200); + + done(); + }); + }); + }); +});