Tests: Start implementing tests
Only convertDateToISOString for now
This commit is contained in:
parent
e04d8857f9
commit
f34245fecc
4 changed files with 3687 additions and 124 deletions
33
.github/workflows/run_node_tests.yml
vendored
Normal file
33
.github/workflows/run_node_tests.yml
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
name: discord bot tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
discord_bot_tests:
|
||||
permissions:
|
||||
contents: read # for actions/checkout to fetch code
|
||||
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
|
||||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
|
||||
runs-on: ubuntu-latest
|
||||
name: discord bot tests
|
||||
steps:
|
||||
# - name: Checkout the code
|
||||
# uses: actions/checkout@v3
|
||||
- name: install node and dependencies
|
||||
run: |
|
||||
apt update
|
||||
apt install curl
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ]
|
||||
printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
run: |
|
||||
npm install
|
||||
- name: run tests
|
||||
run: |
|
||||
npm jest
|
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"
|
||||
}
|
||||
}
|
||||
|
|
13
tests/convertDateToISOString.test.js
Normal file
13
tests/convertDateToISOString.test.js
Normal 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]);
|
||||
}
|
||||
});
|
Loading…
Add table
Reference in a new issue