Files
Leviathan/test/routes/test.test.js
Gregory Ballantine cf4641c8fb
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Added more unit tests
2025-08-19 19:35:55 -04:00

61 lines
1.7 KiB
JavaScript

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