Skip to content

Instantly share code, notes, and snippets.

@nitish24p nitish24p/index.test.js
Last active Nov 20, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.