Lambda-School-Labs/allay-be

View on GitHub
__tests__/companies-router_find_all_companies.spec.js

Summary

Maintainability
B
4 hrs
Test Coverage
const {createCompany, createUser, resetTable, request} = require('./utils/');
const db = require('../data/dbConfig');
const signToken = require('../config/token');
const Company = require('../helpers/companies-model');

const company = createCompany();
const user = createUser();

const token = signToken(user);

describe('Routers Companies', () => {
  beforeAll(async () => {
    await resetTable('companies');
    await db('companies').insert(company);
  });

  describe('GET /api/companies', () => {
    it('Returns correct body', async () => {
      const {body, status, type} = await request('/api/companies', {token});

      expect(status).toEqual(200);
      expect(type).toEqual('application/json');

      const companies = await Company.findCompanies();

      expect(body).toEqual(companies);
    });
  });
});