*.js: test for testing result creation
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
cb0e40ed11
commit
b41568337b
4 changed files with 72 additions and 42 deletions
1
app.js
1
app.js
|
@ -97,7 +97,6 @@ app.get('/asset/frontend.js', (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/newSession', (req, res) => {
|
app.get('/newSession', (req, res) => {
|
||||||
// XXX
|
|
||||||
log.info(req.session)
|
log.info(req.session)
|
||||||
req.session.regenerate()
|
req.session.regenerate()
|
||||||
log.info(req.session)
|
log.info(req.session)
|
||||||
|
|
27
app.test.js
27
app.test.js
|
@ -26,4 +26,31 @@ describe('GET /getNextAnimal', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// vim:set sts=2 sw=2 et:
|
// vim:set sts=2 sw=2 et:
|
||||||
|
|
85
index.html
85
index.html
|
@ -1,47 +1,50 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<title>Is this a Critter?</title>
|
<title>Is this a Critter?</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="isCritter">
|
<div id="isCritter">
|
||||||
<h3>Is this a Critter?</h3>
|
<h3>Is this a Critter?</h3>
|
||||||
<p id="animal-name">what about?:</p>
|
<p id="animal-name">what about?:</p>
|
||||||
<button id="isCritterButton">Is Critter</button>
|
<button id="isCritterButton">Is Critter</button>
|
||||||
<button id="isNotCritterButton">Is <b>not</b> Critter</button>
|
<button id="isNotCritterButton">Is <b>not</b> Critter</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="startOver">
|
<div id="startOver">
|
||||||
<p>
|
<p>
|
||||||
<button id="startOverButton">Start over</button>
|
<button id="startOverButton">Start over</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
© 2023. All rights reserved. <a href="mailto:isacritter@hashbangbash.com">isacritter</a>; <a href="https://paypal.me/vbatts/1" target="_blank">keep isacritter alive</a>
|
© 2023. All rights reserved.
|
||||||
</div>
|
<a href="mailto:isacritter@hashbangbash.com">isacritter</a>;
|
||||||
<script src="/asset/frontend.js"></script>
|
<a href="https://paypal.me/vbatts/1" target="_blank"
|
||||||
<style type="text/css">
|
>keep isacritter alive</a
|
||||||
#animal-name {
|
>
|
||||||
font-size: 25px;
|
</div>
|
||||||
}
|
<script src="/asset/frontend.js"></script>
|
||||||
#isCritter {
|
<style type="text/css">
|
||||||
text-align: center;
|
#animal-name {
|
||||||
}
|
font-size: 25px;
|
||||||
#startOver {
|
}
|
||||||
text-align: center;
|
#isCritter {
|
||||||
}
|
text-align: center;
|
||||||
#footer {
|
}
|
||||||
bottom: 2px;
|
#startOver {
|
||||||
height: 40px;
|
text-align: center;
|
||||||
margin-top: 40px;
|
}
|
||||||
text-align: center;
|
#footer {
|
||||||
vertical-align: middle;
|
bottom: 2px;
|
||||||
position: fixed;
|
height: 40px;
|
||||||
width: 100%;
|
margin-top: 40px;
|
||||||
}
|
text-align: center;
|
||||||
</style>
|
vertical-align: middle;
|
||||||
</body>
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/jest",
|
"test": "./node_modules/.bin/jest",
|
||||||
"lint": "./node_modules/.bin/standard --ignore *.test.js .",
|
"lint": "./node_modules/.bin/standard --ignore *.test.js .",
|
||||||
|
"fix": "./node_modules/.bin/standard --ignore *.test.js --fix .",
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
"act": "act -W ./.gitea/workflows/"
|
"act": "act -W ./.gitea/workflows/"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue