Test fix error checking in include tests #oops

This commit is contained in:
Joey Baker 2016-10-27 12:32:36 -07:00
parent 57f95f8c95
commit f49e4daf79

View File

@ -2,6 +2,8 @@ import test from 'ava';
import 'sinon-bluebird';
import setup from '../test/integration-setup.js';
const STATUS_OK = 200;
setup(test);
test('belongsTo /team?include=city', async (t) => {
@ -9,8 +11,8 @@ test('belongsTo /team?include=city', async (t) => {
const { team1, city1 } = instances;
const path = `/team/${team1.id}?include=city`;
const { result, response } = await server.inject(path);
t.falsy(response instanceof Error);
const { result, statusCode } = await server.inject(path);
t.is(statusCode, STATUS_OK);
t.is(result.id, team1.id);
t.is(result.City.id, city1.id);
});
@ -20,8 +22,8 @@ test('belongsTo /team?include=cities', async (t) => {
const { team1, city1 } = instances;
const path = `/team/${team1.id}?include=cities`;
const { result, response } = await server.inject(path);
t.falsy(response instanceof Error);
const { result, statusCode } = await server.inject(path);
t.is(statusCode, STATUS_OK);
t.is(result.id, team1.id);
t.is(result.City.id, city1.id);
});
@ -31,8 +33,8 @@ test('hasMany /team?include=player', async (t) => {
const { team1, player1, player2 } = instances;
const path = `/team/${team1.id}?include=player`;
const { result, response } = await server.inject(path);
t.falsy(response instanceof Error);
const { result, statusCode } = await server.inject(path);
t.is(statusCode, STATUS_OK);
t.is(result.id, team1.id);
const playerIds = result.Players.map(({ id }) => id);
@ -45,8 +47,8 @@ test('hasMany /team?include=players', async (t) => {
const { team1, player1, player2 } = instances;
const path = `/team/${team1.id}?include=players`;
const { result, response } = await server.inject(path);
t.falsy(response instanceof Error);
const { result, statusCode } = await server.inject(path);
t.is(statusCode, STATUS_OK);
t.is(result.id, team1.id);
const playerIds = result.Players.map(({ id }) => id);
@ -59,8 +61,8 @@ test('multiple includes /team?include=players&include=city', async (t) => {
const { team1, player1, player2, city1 } = instances;
const path = `/team/${team1.id}?include=players&include=city`;
const { result, response } = await server.inject(path);
t.falsy(response instanceof Error);
const { result, statusCode } = await server.inject(path);
t.is(statusCode, STATUS_OK);
t.is(result.id, team1.id);
const playerIds = result.Players.map(({ id }) => id);
@ -74,8 +76,8 @@ test('multiple includes /team?include[]=players&include[]=city', async (t) => {
const { team1, player1, player2, city1 } = instances;
const path = `/team/${team1.id}?include[]=players&include[]=city`;
const { result, response } = await server.inject(path);
t.falsy(response instanceof Error);
const { result, statusCode } = await server.inject(path);
t.is(statusCode, STATUS_OK);
t.is(result.id, team1.id);
const playerIds = result.Players.map(({ id }) => id);