Tests: Start implementing tests

Only convertDateToISOString for now
This commit is contained in:
SileNce5k 2024-10-22 08:53:33 +02:00
parent e04d8857f9
commit 6004f2ad48
Signed by: SileNce
GPG key ID: B0A142BB4291B204
3 changed files with 3654 additions and 124 deletions

3756
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -15,12 +15,15 @@
"valid-url": "^1.0.9"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/SileNce5k/discord_bot.git"
},
"author": "SileNce5k",
"license": "UNLICENSE"
"license": "UNLICENSE",
"devDependencies": {
"jest": "^29.7.0"
}
}

View file

@ -0,0 +1,13 @@
const convertDateToISOString = require('../util/convertDateToISOString');
test('Converts to human readable date string', () => {
let dates = [new Date("1999-12-31 23:55:00"), new Date(0), new Date(5600000), new Date(1000200000000)]
let expectedDateStrings = ["1999-12-31 22:55:00", "1970-01-01 00:00:00", "1970-01-01 01:33:20", "2001-09-11 09:20:00"]
for (let i = 0; i < dates.length; i++) {
expect(convertDateToISOString(dates[i])).toBe(expectedDateStrings[i]);
}
});