Guest User

Untitled

a guest
Jan 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. > router.put( '/:id',
  2. >
  3. > insertAuthorIdToBody, validateSchema(calculatorSchema),
  4. > validateBodyIdMatchesParam('id'), async (req, res, next) => {
  5. > try{
  6. > await addTags(req.body.tags);
  7. > await addCalculator(req.body);
  8. > }catch(err){next(err)}
  9. > res.status(201).json(req.body) } );
  10. >
  11. > describe('PUT /:id', () => {
  12. > it('should return calculator on success request', async () => {
  13. >
  14. > addCalculator.resolves(validCalculator);
  15. > addTags.resolves(validCalculator.tags);
  16. >
  17. > await request(app)
  18. > .put('/new-calculator-uuid')
  19. > .send(validCalculator)
  20. > .set('Accept', 'application/json')
  21. > .expect(201);
  22. >
  23. > await request(app)
  24. > .put('/new-calculator-uuid')
  25. > .send(validCalculator)
  26. > .set('Accept', 'application/json')
  27. > .expect(201, { ...validCalculator, author: user.id });
  28. > });
  29. > it('should return status 500 on server error', async () => {
  30. > addCalculator.rejects();
  31. >
  32. > await request(app)
  33. > .put('/new-calculator-uuid')
  34. > .send(validCalculator)
  35. > .set('Accept', 'application/json')
  36. > .expect(500);
  37. > }); });
Add Comment
Please, Sign In to add comment