Guest User

Untitled

a guest
Nov 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import test from 'ava';
  2. const request = require('supertest');
  3. const app = require('./../app.js');
  4.  
  5.  
  6. test('check status', async t => {
  7. const response = await request(app)
  8. .get('/status');
  9. t.is(response.status, 200);
  10. t.deepEqual(response.body, {
  11. status : 'Ok'
  12. });
  13. })
  14.  
  15. test('greet', async t => {
  16. const name = 'Nitish';
  17. const food = 'Pizza';
  18. const response = await request(app)
  19. .get('/greet')
  20. .query({name, food});
  21.  
  22. t.is(response.status, 200);
  23. t.is(response.body.message, `hello ${name} would you like a ${food}`);
  24. })
  25.  
  26.  
  27. test('Dont send username', async t => {
  28. const password = 'some-hase'
  29. const response = await request(app)
  30. .post('/register')
  31. .send({password});
  32.  
  33. t.is(response.status, 400);
  34. t.is(response.body.message, `username is missing`);
  35. })
  36.  
  37.  
  38. test('Dont send password', async t => {
  39. const username = 'some-hase'
  40. const response = await request(app)
  41. .post('/register')
  42. .send({username});
  43.  
  44.  
  45. t.is(response.status, 400);
  46. t.is(response.body.message, `password is missing`);
  47. })
Add Comment
Please, Sign In to add comment