Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > router.put( '/:id',
- >
- > insertAuthorIdToBody, validateSchema(calculatorSchema),
- > validateBodyIdMatchesParam('id'), async (req, res, next) => {
- > try{
- > await addTags(req.body.tags);
- > await addCalculator(req.body);
- > }catch(err){next(err)}
- > res.status(201).json(req.body) } );
- >
- > describe('PUT /:id', () => {
- > it('should return calculator on success request', async () => {
- >
- > addCalculator.resolves(validCalculator);
- > addTags.resolves(validCalculator.tags);
- >
- > await request(app)
- > .put('/new-calculator-uuid')
- > .send(validCalculator)
- > .set('Accept', 'application/json')
- > .expect(201);
- >
- > await request(app)
- > .put('/new-calculator-uuid')
- > .send(validCalculator)
- > .set('Accept', 'application/json')
- > .expect(201, { ...validCalculator, author: user.id });
- > });
- > it('should return status 500 on server error', async () => {
- > addCalculator.rejects();
- >
- > await request(app)
- > .put('/new-calculator-uuid')
- > .send(validCalculator)
- > .set('Accept', 'application/json')
- > .expect(500);
- > }); });
Add Comment
Please, Sign In to add comment