2023-09-22 20:39:37 +00:00
|
|
|
// app.test.js
|
2023-09-29 01:31:05 +00:00
|
|
|
const request = require('supertest')
|
|
|
|
const app = require('./app')
|
2023-09-22 20:39:37 +00:00
|
|
|
|
|
|
|
describe('GET /', () => {
|
|
|
|
it('should respond with 200 status', async () => {
|
2023-09-29 01:31:05 +00:00
|
|
|
const response = await request(app).get('/')
|
|
|
|
expect(response.statusCode).toBe(200)
|
|
|
|
// expect(response.body.message).toBe('Hello, World!');
|
|
|
|
})
|
|
|
|
})
|
2023-09-22 20:39:37 +00:00
|
|
|
|
|
|
|
describe('GET /asset/frontend.js', () => {
|
|
|
|
it('should respond with 200 status', async () => {
|
2023-09-29 01:31:05 +00:00
|
|
|
const response = await request(app).get('/asset/frontend.js')
|
|
|
|
expect(response.statusCode).toBe(200)
|
|
|
|
// expect(response.body.message).toBe('Hello, World!');
|
|
|
|
})
|
|
|
|
})
|
2023-09-22 20:39:37 +00:00
|
|
|
|
|
|
|
describe('GET /getNextAnimal', () => {
|
|
|
|
it('should respond with 200 status', async () => {
|
2023-09-29 01:31:05 +00:00
|
|
|
const response = await request(app).get('/getNextAnimal')
|
|
|
|
expect(response.statusCode).toBe(200)
|
|
|
|
// expect(response.body.message).toBe('Hello, World!');
|
|
|
|
})
|
|
|
|
})
|
2023-09-22 20:39:37 +00:00
|
|
|
|
2023-09-29 14:34:45 +00:00
|
|
|
describe('POST /recordButtonClick', () => {
|
|
|
|
const bodyData = JSON.stringify({
|
|
|
|
animal: 'SlartyBartFast',
|
|
|
|
button: 'is critter',
|
|
|
|
session: 'dang',
|
|
|
|
difference: 1234,
|
|
|
|
time: new Date()
|
|
|
|
})
|
|
|
|
it('should respond with 200 status', async () => {
|
|
|
|
const response = await request(app)
|
|
|
|
.post('/recordButtonClick')
|
|
|
|
.send(bodyData)
|
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
expect(response.statusCode).toBe(200)
|
|
|
|
// expect(response.body.message).toBe('Hello, World!');
|
|
|
|
})
|
|
|
|
it('have a result', async () => {
|
|
|
|
const response = await request(app)
|
|
|
|
.get('/results')
|
|
|
|
expect(response.statusCode).toBe(200)
|
|
|
|
//console.log(response.body)
|
|
|
|
expect(response.body.count.SlartyBartFast['is critter']).toBe(1)
|
|
|
|
expect(response.body.avgTimes.SlartyBartFast.total).toBe(1234)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-09-22 20:39:37 +00:00
|
|
|
// vim:set sts=2 sw=2 et:
|