Last active
July 24, 2018 14:49
-
-
Save Lumexralph/2680ed1384fa9a246ee5ea482c08d518 to your computer and use it in GitHub Desktop.
This file contains 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
import expect from 'expect'; | |
import request from 'supertest'; | |
import app from '../app'; // the web server | |
const mockData = { | |
"article": { | |
"title": "", | |
"description": "Ever wonder how?", | |
"body": "You have to believe", | |
"tagList": ["reactjs", "angularjs", "dragons"] | |
} | |
} | |
describe('POST /api/articles create an article', () =>{ | |
it('should not create the article when title is empty', (done) => { | |
request(app) | |
.post('/api/articles') | |
.send(mockdata) | |
.expect(400) | |
.expect(res => { | |
expect(res.body).toHaveProperty('errors'); | |
expect(res.body.errors.body.length).toBe(1); | |
expect(res.body.errors.body[0]).toBe('can\'t be empty'); | |
}) | |
.end(done); | |
} | |
}); |
Creating an article without a title will be impossible to generate a slug. Good job providing a test that ensures that the article should not be created if the title property is empty.
Great job on taking the initiative to add a test to check for title property before creating an article, this will ensure that an article does not get created with an incomplete data.
Great one. One little something though, imports come first :P.
Nice work!, Well laid out. Kudos.
Nice one! You checked for an empty title, I bet no user will be able to create an article without a title with this test, that's fine, keep it up.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good job on your TDD, great initiative on thinking about the possible scenarios.