Last active
July 1, 2020 11:10
-
-
Save kianaditya/8bae97b23716601049808e1e9a7269f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('supertest') | |
const app = require('../src/app') | |
const expect = require('chai').expect | |
describe('GET /posts endpoint', () => { | |
it('GET /posts endpoint successfully returns response', () => { | |
return request(app) | |
.get('/posts') | |
.then((response) => { | |
expect(response.statusCode).to.equal(200) | |
expect(response.body) | |
.to.be.an.instanceof(Array) | |
.and.to.have.length(4) | |
.and.to.have.property(0) | |
.that.includes.all.keys(['id', 'title', 'content', 'Author']) | |
.and.to.have.nested.property('Author') | |
.to.be.an.instanceof(Object) | |
.that.includes.all.keys(['firstName', 'lastName']) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment