*.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) => {
|
||||
// XXX
|
||||
log.info(req.session)
|
||||
req.session.regenerate()
|
||||
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:
|
||||
|
|
85
index.html
85
index.html
|
@ -1,47 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Is this a Critter?</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="isCritter">
|
||||
<h3>Is this a Critter?</h3>
|
||||
<p id="animal-name">what about?:</p>
|
||||
<button id="isCritterButton">Is Critter</button>
|
||||
<button id="isNotCritterButton">Is <b>not</b> Critter</button>
|
||||
</div>
|
||||
</head>
|
||||
<body>
|
||||
<div id="isCritter">
|
||||
<h3>Is this a Critter?</h3>
|
||||
<p id="animal-name">what about?:</p>
|
||||
<button id="isCritterButton">Is Critter</button>
|
||||
<button id="isNotCritterButton">Is <b>not</b> Critter</button>
|
||||
</div>
|
||||
|
||||
<div id="startOver">
|
||||
<p>
|
||||
<button id="startOverButton">Start over</button>
|
||||
</p>
|
||||
</div>
|
||||
<div id="startOver">
|
||||
<p>
|
||||
<button id="startOverButton">Start over</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<script src="/asset/frontend.js"></script>
|
||||
<style type="text/css">
|
||||
#animal-name {
|
||||
font-size: 25px;
|
||||
}
|
||||
#isCritter {
|
||||
text-align: center;
|
||||
}
|
||||
#startOver {
|
||||
text-align: center;
|
||||
}
|
||||
#footer {
|
||||
bottom: 2px;
|
||||
height: 40px;
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
<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
|
||||
>
|
||||
</div>
|
||||
<script src="/asset/frontend.js"></script>
|
||||
<style type="text/css">
|
||||
#animal-name {
|
||||
font-size: 25px;
|
||||
}
|
||||
#isCritter {
|
||||
text-align: center;
|
||||
}
|
||||
#startOver {
|
||||
text-align: center;
|
||||
}
|
||||
#footer {
|
||||
bottom: 2px;
|
||||
height: 40px;
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"scripts": {
|
||||
"test": "./node_modules/.bin/jest",
|
||||
"lint": "./node_modules/.bin/standard --ignore *.test.js .",
|
||||
"fix": "./node_modules/.bin/standard --ignore *.test.js --fix .",
|
||||
"start": "node server.js",
|
||||
"act": "act -W ./.gitea/workflows/"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue