Tests: Start implementing tests
All checks were successful
discord bot tests / discord bot tests (push) Successful in 10s
All checks were successful
discord bot tests / discord bot tests (push) Successful in 10s
Only convertDateToISOString for now
This commit is contained in:
parent
e04d8857f9
commit
10934bb04f
4 changed files with 3671 additions and 124 deletions
18
.github/workflows/run_node_tests.yml
vendored
Normal file
18
.github/workflows/run_node_tests.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
name: discord bot tests
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
discord_bot_tests:
|
||||
runs-on: node
|
||||
name: discord bot tests
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'latest'
|
||||
- name: install dependencies
|
||||
run: npm install
|
||||
- name: run tests
|
||||
run: npm test
|
3758
package-lock.json
generated
3758
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
12
tests/convertDateToISOString.test.js
Normal file
12
tests/convertDateToISOString.test.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
const convertDateToISOString = require('../util/convertDateToISOString');
|
||||
|
||||
|
||||
let dates = [new Date("2020-01-01"), new Date(0), new Date(5600000), new Date(1000200000000)]
|
||||
let expectedDateStrings = ["2020-01-01 00:00: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++) {
|
||||
|
||||
test('Converts to human readable date string', () => {
|
||||
expect(convertDateToISOString(dates[i])).toBe(expectedDateStrings[i]);
|
||||
});
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue