Last active
November 20, 2017 18:16
-
-
Save nitish24p/3bb790a8ed78f75214485bf237df6439 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 test from 'ava'; | |
const request = require('supertest'); | |
const app = require('./../app.js'); | |
test('check status', async t => { | |
const response = await request(app) | |
.get('/status'); | |
t.is(response.status, 200); | |
t.deepEqual(response.body, { | |
status : 'Ok' | |
}); | |
}) | |
test('greet', async t => { | |
const name = 'Nitish'; | |
const food = 'Pizza'; | |
const response = await request(app) | |
.get('/greet') | |
.query({name, food}); | |
t.is(response.status, 200); | |
t.is(response.body.message, `hello ${name} would you like a ${food}`); | |
}) | |
test('Dont send username', async t => { | |
const password = 'some-hase' | |
const response = await request(app) | |
.post('/register') | |
.send({password}); | |
t.is(response.status, 400); | |
t.is(response.body.message, `username is missing`); | |
}) | |
test('Dont send password', async t => { | |
const username = 'some-hase' | |
const response = await request(app) | |
.post('/register') | |
.send({username}); | |
t.is(response.status, 400); | |
t.is(response.body.message, `password is missing`); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment