-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathindex.test.js
More file actions
36 lines (32 loc) · 1.1 KB
/
index.test.js
File metadata and controls
36 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const request = require('supertest');
// express app
const app = require('./index');
// db setup
const { sequelize, Dog } = require('./db');
const seed = require('./db/seedFn');
const {dogs} = require('./db/seedData');
describe('Endpoints', () => {
// to be used in POST test
const testDogData = {
breed: 'Poodle',
name: 'Sasha',
color: 'black',
description: 'Sasha is a beautiful black pooodle mix. She is a great companion for her family.'
};
beforeAll(async () => {
// rebuild db before the test suite runs
await seed();
});
describe('GET /dogs', () => {
it('should return list of dogs with correct data', async () => {
// make a request
const response = await request(app).get('/dogs');
// assert a response code
expect(response.status).toBe(200);
// expect a response
expect(response.body).toBeDefined();
// toEqual checks deep equality in objects
expect(response.body[0]).toEqual(expect.objectContaining(dogs[0]));
});
});
});