Merge pull request #336 from cvan/test-game-detail

add test for `GET /games/{idOrSlug}` hapi endpoint (fixes #302)
This commit is contained in:
Chris Van 2015-01-14 02:26:15 -08:00
Родитель 8d7028941e 58a7078eb3
Коммит 701b298f2a
1 изменённых файлов: 53 добавлений и 1 удалений

Просмотреть файл

@ -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();
});
});
});
});