Added more unit tests
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2025-08-19 19:35:55 -04:00
parent 512f7f169e
commit cf4641c8fb
4 changed files with 102 additions and 17 deletions

View File

@@ -8,11 +8,15 @@ describe('GET /test', () => {
this.res = res;
});
it('should return a redirect', async () => {
it('Test base route should return a redirect', async () => {
expect(this.res.status).to.equal(302);
});
it('should redirect to /test/list', async () => {
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');
});
});
@@ -23,11 +27,34 @@ describe('GET /test/list', () => {
this.res = res;
});
it('should return a 200 status', async () => {
it('Test list route should return a 200 status', async () => {
expect(this.res.status).to.equal(200);
});
it('should return an HTML response', async () => {
expect(this.res.headers['content-type']).match(/text\/html/);
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');
});
});