Compare commits
3 commits
0ca11f398b
...
4ca13712ed
Author | SHA1 | Date | |
---|---|---|---|
4ca13712ed | |||
000f7e969c | |||
10934bb04f |
5 changed files with 3710 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
|
3768
package-lock.json
generated
3768
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -15,12 +15,16 @@
|
|||
"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": {
|
||||
"@types/jest": "^29.5.13",
|
||||
"jest": "^29.7.0"
|
||||
}
|
||||
}
|
||||
|
|
26
tests/calculateReloaded.test.js
Normal file
26
tests/calculateReloaded.test.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const calculateReloaded = require('../util/calculateReloaded')
|
||||
|
||||
let client = {commands: new Map()};
|
||||
for(let i = 0; i < 10; i++){
|
||||
client.commands.set(i, i * 420);
|
||||
}
|
||||
let beforeSizes = [0, 12, 10, 9, 11, 6, 104];
|
||||
let expectedResults = [
|
||||
`10 modules were added, and a total of 10 were reloaded.`,
|
||||
`10 modules were reloaded after 2 were disabled.`,
|
||||
`10 modules were reloaded.`,
|
||||
`1 module was added, and a total of 10 were reloaded.`,
|
||||
`10 modules were reloaded after 1 module was deleted.`,
|
||||
`4 modules were added, and a total of 10 were reloaded.`,
|
||||
`10 modules were reloaded after 94 were disabled.`
|
||||
]
|
||||
|
||||
if(beforeSizes.length != expectedResults.length) throw "Error: beforeSizes and expectedResults are unequal length"
|
||||
|
||||
for(let i = 0; i < beforeSizes.length; i++){
|
||||
test('calculateReloaded test', () => {
|
||||
expect(calculateReloaded(beforeSizes[i], client)).toBe(expectedResults[i])
|
||||
|
||||
});
|
||||
|
||||
}
|
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