Lambda-School-Labs/allay-be

View on GitHub
__tests__/middleware_restricted.spec.js

Summary

Maintainability
A
0 mins
Test Coverage
const {request} = require('./utils/');
const {MISSING_TOKEN_ERROR} = require('../config/errors.js');

describe('Middleware', () => {
  describe('restricted', () => {
    it('Token is needed for endpoints', async () => {
      const {body, status, type} = await request('/api/reviews');

      expect(status).toBe(401);
      expect(type).toBe('application/json');
      expect(body).toEqual({message: MISSING_TOKEN_ERROR});
    });
  });
});