const request = require('supertest'); const { expect } = require('chai'); const app = require('../../src/app'); describe('GET /hardware', () => { beforeEach(async () => { const res = await request(app).get('/hardware'); this.res = res; }); it('Hardware base route should return a redirect', async () => { expect(this.res.status).to.equal(302); }); it('Hardware base route should return an HTML response', async () => { expect(this.res.headers['content-type']).contains('text/plain'); }); it('Hardware base route should redirect to /hardware/list', async () => { expect(this.res.headers['location']).contains('/hardware/list'); }); }); describe('GET /hardware/list', () => { beforeEach(async () => { const res = await request(app).get('/hardware/list'); this.res = res; }); it('Hardware list route should return a 200 status', async () => { expect(this.res.status).to.equal(200); }); it('Hardware list route should return an HTML response', async () => { expect(this.res.headers['content-type']).contains('text/html'); }); it('Hardware list route should contain "List of Hardware" in body', async() => { expect(this.res.text).contains('List of Hardware'); }); }); describe('GET /hardware/add', () => { beforeEach(async () => { const res = await request(app).get('/hardware/add'); this.res = res; }); it('Hardware add route should return a 200 status', async () => { expect(this.res.status).to.equal(200); }); it('Hardware add route should return an HTML response', async () => { expect(this.res.headers['content-type']).contains('text/html'); }); it('Hardware add route should contain "Add Hardware" in body', async() => { expect(this.res.text).contains('Add Hardware'); }); });