This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"dev": "nodemon ./index.js",
|
"dev": "nodemon ./index.js",
|
||||||
"test": "mocha",
|
"test": "mocha \"test/**/*.test.js\"",
|
||||||
"grunt": "grunt"
|
"grunt": "grunt"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@@ -3,8 +3,16 @@ const { expect } = require('chai');
|
|||||||
const app = require('../src/app');
|
const app = require('../src/app');
|
||||||
|
|
||||||
describe('GET /', () => {
|
describe('GET /', () => {
|
||||||
it('should run the app server', async () => {
|
beforeEach(async () => {
|
||||||
const res = await request(app).get('/');
|
const res = await request(app).get('/');
|
||||||
expect(res.status).to.equal(200);
|
this.res = res;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should run the app server', async () => {
|
||||||
|
expect(this.res.status).to.equal(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return an HTML response', async () => {
|
||||||
|
expect(this.res.headers['content-type']).match(/text\/html/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
33
test/routes/benchmark.test.js
Normal file
33
test/routes/benchmark.test.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const request = require('supertest');
|
||||||
|
const { expect } = require('chai');
|
||||||
|
const app = require('../../src/app');
|
||||||
|
|
||||||
|
describe('GET /benchmark', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
const res = await request(app).get('/benchmark');
|
||||||
|
this.res = res;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a redirect', async () => {
|
||||||
|
expect(this.res.status).to.equal(302);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should redirect to /benchmark/list', async () => {
|
||||||
|
expect(this.res.headers['location']).contains('/benchmark/list');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('GET /benchmark/list', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
const res = await request(app).get('/benchmark/list');
|
||||||
|
this.res = res;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('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/);
|
||||||
|
});
|
||||||
|
});
|
33
test/routes/hardware.test.js
Normal file
33
test/routes/hardware.test.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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('should return a redirect', async () => {
|
||||||
|
expect(this.res.status).to.equal(302);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('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('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/);
|
||||||
|
});
|
||||||
|
});
|
33
test/routes/test.test.js
Normal file
33
test/routes/test.test.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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('should return a redirect', async () => {
|
||||||
|
expect(this.res.status).to.equal(302);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('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('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/);
|
||||||
|
});
|
||||||
|
});
|
18
test/routes/toplevel.test.js
Normal file
18
test/routes/toplevel.test.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
const request = require('supertest');
|
||||||
|
const { expect } = require('chai');
|
||||||
|
const app = require('../../src/app');
|
||||||
|
|
||||||
|
describe('GET /', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
const res = await request(app).get('/');
|
||||||
|
this.res = res;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('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/);
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user