Skip to content

Instantly share code, notes, and snippets.

@nitish24p
Last active November 20, 2017 18:16
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 nitish24p/3bb790a8ed78f75214485bf237df6439 to your computer and use it in GitHub Desktop.
Save nitish24p/3bb790a8ed78f75214485bf237df6439 to your computer and use it in GitHub Desktop.
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