Skip to content

Instantly share code, notes, and snippets.

@tehvicke
Created February 14, 2020 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tehvicke/1a1c9cb70a1f5cbb81f558b25ef96853 to your computer and use it in GitHub Desktop.
Save tehvicke/1a1c9cb70a1f5cbb81f558b25ef96853 to your computer and use it in GitHub Desktop.
Endpoint testing
describe('route testing', () => {
it('can get thoughts', async () => {
await request(server)
.get('/')
.expect(200)
}),
it('can post thoughts', async () => {
await request(server)
.post('/')
.send({ message: 'test message' })
.expect(200)
}),
it('returns error if message is less than 5 characters or longer than 140', async () => {
await request(server)
.post('/')
.send({ message: 'fail' })
.expect(500)
let msg = 'fail'
for (let i = 0; i < 50; i++) {
msg += 'fail'
}
await request(server)
.post('/')
.send({ message: msg })
.expect(500)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment