Skip to content

Commit 21109c9

Browse files
author
Sv443
committed
added base for adding unit tests
1 parent 476de71 commit 21109c9

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ node_modules/
1616
dev/madge/
1717
dependency-graph.html
1818
test.js
19+
!tools/test.js
1920

2021
# Docs:
2122
docs/documentation.html

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"homepage": "https://sv443.net/jokeapi/v2",
77
"scripts": {
88
"start": "node . && exit $?",
9-
"test": "snyk test && echo \"No test script specified\" && exit 0",
9+
"test": "snyk test && node tools/test",
1010
"reformat": "node tools/reformat",
1111
"reassign-ids": "node tools/reassign-ids",
1212
"validate-jokes": "node tools/validate-jokes",

settings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,13 @@ const settings = {
188188
tokenValidHeader: "Token-Valid", // the name of the token validity response header (normal case, not lower case)
189189
daemonInterval: 20, // after how many seconds the auth tokens should be refreshed
190190
},
191-
languages:
192-
{
191+
languages: {
193192
langFilePath: "./data/languages.json", // file containing all language codes and corresponding language information
194193
defaultLanguage: "en", // default language (two character code, lowercase)
195194
translationsFile: "./data/translations.json", // translations file
195+
},
196+
tests: { // unit tests
197+
location: "./tests/", // folder where unit tests are located - requires trailing slash
196198
}
197199
}
198200

tests/joke-endpoint.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const settings = require("../settings");
2+
3+
const meta = {
4+
name: "Joke",
5+
category: "Endpoints",
6+
endpointURL: "/joke"
7+
};
8+
9+
/**
10+
* @typedef {Object} UnitTestResult
11+
* @prop {String} name
12+
* @prop {Boolean} success
13+
*/
14+
15+
/**
16+
* Runs this unit test
17+
* @returns {Promise<Array<UnitTestResult>, String>}
18+
*/
19+
function run()
20+
{
21+
return new Promise((resolve, reject) => {
22+
23+
});
24+
}
25+
26+
module.exports = { meta, run };

tools/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const settings = require("../settings");
2+
3+
4+
5+
function getAllTests()
6+
{
7+
8+
}
9+
10+
function runAllTests()
11+
{
12+
let tests = getAllTests();
13+
}
14+
15+
runAllTests();

0 commit comments

Comments
 (0)