From 633ada9fc95a0277f9c11ba0ef1e2b037fc06fcc Mon Sep 17 00:00:00 2001 From: Daryl Ronningen Date: Thu, 17 Jun 2021 04:46:58 -0700 Subject: [PATCH] test: added placeholder tests --- .husky/pre-commit | 1 + .nycrc.json | 7 ++ package.json | 9 ++ rollup.config.js | 17 ++++ tests/placeholder.test.ts | 23 +++++ yarn.lock | 202 +++++++++++++++++++++++++++++++++++++- 6 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 .nycrc.json create mode 100644 tests/placeholder.test.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index d2ae35e..59d409c 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,3 +2,4 @@ . "$(dirname "$0")/_/husky.sh" yarn lint-staged +yarn test \ No newline at end of file diff --git a/.nycrc.json b/.nycrc.json new file mode 100644 index 0000000..f33aaae --- /dev/null +++ b/.nycrc.json @@ -0,0 +1,7 @@ +{ + "extends": "@istanbuljs/nyc-config-typescript", + "all": true, + "check-coverage": true, + "include": ["src/**/*.ts"], + "reporter": ["html"] +} \ No newline at end of file diff --git a/package.json b/package.json index 2c25eb0..8293c2c 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "compile:dev": "tsc", "compile:prod": "rollup -c --compact", "commit": "commit", + "coverage": "nyc yarn run test", "lint": "eslint --format=pretty src/**/*.ts", "lint:save": "eslint --format=pretty --save src/**/*.ts", "postinstall": "husky install", @@ -26,6 +27,7 @@ "release:full": "standard-version -s", "run:dev": "node dist/src/index.js --dev", "run:prod": "node dist/index.js", + "test": "mocha -r ts-node/register tests/**/*.test.ts", "watch:bot": "nodemon dist/src/index.js --dev", "watch:rollup": "tsc --watch", "watch:tsc": "tsc --watch" @@ -56,20 +58,25 @@ "@commitlint/cli": "^12.1.4", "@commitlint/config-conventional": "^12.1.4", "@commitlint/prompt-cli": "^12.1.4", + "@istanbuljs/nyc-config-typescript": "^1.0.1", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-typescript": "^8.2.1", + "@types/chai": "^4.2.18", "@types/color-convert": "^2", "@types/eslint": "^7.2.13", "@types/figlet": "^1.5.1", "@types/gradient-string": "^1", "@types/luxon": "^1", + "@types/mocha": "^8.2.2", "@types/node": "^15.12.2", "@types/rimraf": "^3", + "@types/std-mocks": "^1", "@types/yargs": "^17", "@typescript-eslint/eslint-plugin": "^4.27.0", "@typescript-eslint/parser": "^4.27.0", "@typescript-eslint/typescript-estree": "^4.27.0", "@yarnpkg/pnpify": "^3.0.0-rc.6", + "chai": "^4.3.4", "eslint": "^7.28.0", "eslint-formatter-pretty": "^4.1.0", "eslint-plugin-header": "^3.1.1", @@ -82,6 +89,8 @@ "rollup": "^2.52.0", "rollup-plugin-terser": "^7.0.2", "standard-version": "^9.3.0", + "std-mocks": "^1.0.1", + "ts-node": "^10.0.0", "typescript": "^4.3.3", "typescript-eslint-language-service": "^4.1.4" }, diff --git a/rollup.config.js b/rollup.config.js index 14687dc..c84748a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,23 @@ +/* + * This file is part of ArgonBot + * + * ArgonBot is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ArgonBot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ArgonBot. If not, see . + */ import typescript from '@rollup/plugin-typescript'; import json from '@rollup/plugin-json'; import { terser } from 'rollup-plugin-terser'; + export default { input: 'src/index.ts', output: { diff --git a/tests/placeholder.test.ts b/tests/placeholder.test.ts new file mode 100644 index 0000000..5da8d0f --- /dev/null +++ b/tests/placeholder.test.ts @@ -0,0 +1,23 @@ +/* + * This file is part of ArgonBot + * + * ArgonBot is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ArgonBot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ArgonBot. If not, see . + */ +import { describe, it } from 'mocha'; + +describe('placeholder', () => { + it('placeholder', () => { + return true; + }); +}); diff --git a/yarn.lock b/yarn.lock index 0c2405e..e4c5438 100644 --- a/yarn.lock +++ b/yarn.lock @@ -571,6 +571,19 @@ __metadata: languageName: node linkType: hard +"@istanbuljs/nyc-config-typescript@npm:^1.0.1": + version: 1.0.1 + resolution: "@istanbuljs/nyc-config-typescript@npm:1.0.1" + dependencies: + "@istanbuljs/schema": ^0.1.2 + peerDependencies: + nyc: ">=15" + source-map-support: "*" + ts-node: "*" + checksum: b4106446f88a637a0b168d1fcee73510de0c403584dc2722e507c5fd874b2cb1e513349d63f2cfc6d58aa59f153cd66e910bb3c80c65a37ca01f8aafc484dffd + languageName: node + linkType: hard + "@istanbuljs/schema@npm:^0.1.2": version: 0.1.3 resolution: "@istanbuljs/schema@npm:0.1.3" @@ -699,6 +712,34 @@ __metadata: languageName: node linkType: hard +"@tsconfig/node10@npm:^1.0.7": + version: 1.0.8 + resolution: "@tsconfig/node10@npm:1.0.8" + checksum: b8d5fffbc6b17ef64ef74f7fdbccee02a809a063ade785c3648dae59406bc207f70ea2c4296f92749b33019fa36a5ae716e42e49cc7f1bbf0fd147be0d6b970a + languageName: node + linkType: hard + +"@tsconfig/node12@npm:^1.0.7": + version: 1.0.8 + resolution: "@tsconfig/node12@npm:1.0.8" + checksum: c227ef3ae7c2b2f76861e7371eca8c8e4d9e8ef12f55c3da20b2d17283f6811675529875f49f23f80d4c3e0b94f0643fd17ce8afdd842bdd5aa97d6d0cbc12dd + languageName: node + linkType: hard + +"@tsconfig/node14@npm:^1.0.0": + version: 1.0.1 + resolution: "@tsconfig/node14@npm:1.0.1" + checksum: 976345e896c0f059867f94f8d0f6ddb8b1844fb62bf36b727de8a9a68f024857e5db97ed51d3325e23e0616a5e48c034ff51a8d595b3fe7e955f3587540489be + languageName: node + linkType: hard + +"@tsconfig/node16@npm:^1.0.1": + version: 1.0.1 + resolution: "@tsconfig/node16@npm:1.0.1" + checksum: 5fdfd91e48dc1f406cb59d19fd450a594ea6279f3be54a50bd6fd6b8d189a53bb930f2e7d496cbc3bb45fbb23f0ce5c69086f90c796ce8441cbd2a26fb738fd5 + languageName: node + linkType: hard + "@types/cacheable-request@npm:^6.0.1": version: 6.0.1 resolution: "@types/cacheable-request@npm:6.0.1" @@ -711,6 +752,13 @@ __metadata: languageName: node linkType: hard +"@types/chai@npm:^4.2.18": + version: 4.2.18 + resolution: "@types/chai@npm:4.2.18" + checksum: 786544dd4d853b40d798fd25c74fa21540227af5c305dd4da4a64f6ec07b61a553e9f2b23a26f2afe71e0487dc7c2edc0e877c06d82c13c4e6b6e6a42d045490 + languageName: node + linkType: hard + "@types/color-convert@npm:^2": version: 2.0.0 resolution: "@types/color-convert@npm:2.0.0" @@ -828,6 +876,13 @@ __metadata: languageName: node linkType: hard +"@types/mocha@npm:^8.2.2": + version: 8.2.2 + resolution: "@types/mocha@npm:8.2.2" + checksum: 8e1fbc3e98d6bd93fe5b7454c34d53241b9f1947b28c10b8bb340585a9ed303be649b45c36b19236000f82f74e8d3df67ed617ae7baae80ea09d5317dbe080ba + languageName: node + linkType: hard + "@types/node@npm:*, @types/node@npm:^15.12.2": version: 15.12.2 resolution: "@types/node@npm:15.12.2" @@ -889,6 +944,13 @@ __metadata: languageName: node linkType: hard +"@types/std-mocks@npm:^1": + version: 1.0.0 + resolution: "@types/std-mocks@npm:1.0.0" + checksum: acbdcbe8871897f3d5536b64835038992823c021ae4669c5cbe0641df0c8f6bed652f25f7e2de3c27c648c8650acb2195194b5edea0eefbbe50d9a6681d1beef + languageName: node + linkType: hard + "@types/tinycolor2@npm:*, @types/tinycolor2@npm:^1.4.0": version: 1.4.2 resolution: "@types/tinycolor2@npm:1.4.2" @@ -1423,6 +1485,13 @@ __metadata: languageName: node linkType: hard +"arg@npm:^4.1.0": + version: 4.1.3 + resolution: "arg@npm:4.1.3" + checksum: 544af8dd3f60546d3e4aff084d451b96961d2267d668670199692f8d054f0415d86fc5497d0e641e91546f0aa920e7c29e5250e99fc89f5552a34b5d93b77f43 + languageName: node + linkType: hard + "argon-bot@workspace:.": version: 0.0.0-use.local resolution: "argon-bot@workspace:." @@ -1432,21 +1501,26 @@ __metadata: "@commitlint/prompt-cli": ^12.1.4 "@discordjs/opus": ^0.5.3 "@discordjs/voice": ^0.5.0 + "@istanbuljs/nyc-config-typescript": ^1.0.1 "@rollup/plugin-json": ^4.1.0 "@rollup/plugin-typescript": ^8.2.1 + "@types/chai": ^4.2.18 "@types/color-convert": ^2 "@types/eslint": ^7.2.13 "@types/figlet": ^1.5.1 "@types/gradient-string": ^1 "@types/luxon": ^1 + "@types/mocha": ^8.2.2 "@types/node": ^15.12.2 "@types/rimraf": ^3 + "@types/std-mocks": ^1 "@types/yargs": ^17 "@typescript-eslint/eslint-plugin": ^4.27.0 "@typescript-eslint/parser": ^4.27.0 "@typescript-eslint/typescript-estree": ^4.27.0 "@yarnpkg/pnpify": ^3.0.0-rc.6 bufferutil: ^4.0.3 + chai: ^4.3.4 chalk: ^4.1.1 color-convert: ^2.0.1 discord.js: ^13.0.0-dev.a3cbcca13da1af416c219bd64a0a6e84bb87a057 @@ -1470,8 +1544,10 @@ __metadata: rollup-plugin-terser: ^7.0.2 sodium: ^3.0.2 standard-version: ^9.3.0 + std-mocks: ^1.0.1 supports-color: ^9.0.1 terminal-link: ^3.0.0 + ts-node: ^10.0.0 tslib: ^2.3.0 typescript: ^4.3.3 typescript-eslint-language-service: ^4.1.4 @@ -1532,6 +1608,13 @@ __metadata: languageName: node linkType: hard +"assertion-error@npm:^1.1.0": + version: 1.1.0 + resolution: "assertion-error@npm:1.1.0" + checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf + languageName: node + linkType: hard + "astral-regex@npm:^2.0.0": version: 2.0.0 resolution: "astral-regex@npm:2.0.0" @@ -1818,6 +1901,20 @@ __metadata: languageName: node linkType: hard +"chai@npm:^4.3.4": + version: 4.3.4 + resolution: "chai@npm:4.3.4" + dependencies: + assertion-error: ^1.1.0 + check-error: ^1.0.2 + deep-eql: ^3.0.1 + get-func-name: ^2.0.0 + pathval: ^1.1.1 + type-detect: ^4.0.5 + checksum: 772c522b3bfe3fcf0e0e74edfe584cd886b0e85a73126dec750095300e023d4e1ec6d40e3c35a80d2bd8f33dca46c42767a36f5f50f32dca6fa31c88b5f49ab8 + languageName: node + linkType: hard + "chalk@npm:^1.0.0, chalk@npm:^1.1.0": version: 1.1.3 resolution: "chalk@npm:1.1.3" @@ -1862,6 +1959,13 @@ __metadata: languageName: node linkType: hard +"check-error@npm:^1.0.2": + version: 1.0.2 + resolution: "check-error@npm:1.0.2" + checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e + languageName: node + linkType: hard + "chokidar@npm:3.5.1": version: 3.5.1 resolution: "chokidar@npm:3.5.1" @@ -2408,6 +2512,13 @@ __metadata: languageName: node linkType: hard +"create-require@npm:^1.1.0": + version: 1.1.1 + resolution: "create-require@npm:1.1.1" + checksum: a9a1503d4390d8b59ad86f4607de7870b39cad43d929813599a23714831e81c520bddf61bcdd1f8e30f05fd3a2b71ae8538e946eb2786dc65c2bbc520f692eff + languageName: node + linkType: hard + "cross-spawn@npm:7.0.3, cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -2540,6 +2651,15 @@ __metadata: languageName: node linkType: hard +"deep-eql@npm:^3.0.1": + version: 3.0.1 + resolution: "deep-eql@npm:3.0.1" + dependencies: + type-detect: ^4.0.0 + checksum: 4f4c9fb79eb994fb6e81d4aa8b063adc40c00f831588aa65e20857d5d52f15fb23034a6576ecf886f7ff6222d5ae42e71e9b7d57113e0715b1df7ea1e812b125 + languageName: node + linkType: hard + "deep-extend@npm:^0.6.0": version: 0.6.0 resolution: "deep-extend@npm:0.6.0" @@ -3377,6 +3497,13 @@ __metadata: languageName: node linkType: hard +"get-func-name@npm:^2.0.0": + version: 2.0.0 + resolution: "get-func-name@npm:2.0.0" + checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 + languageName: node + linkType: hard + "get-intrinsic@npm:^1.0.2": version: 1.1.1 resolution: "get-intrinsic@npm:1.1.1" @@ -4666,7 +4793,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.21, lodash@npm:^4.5.1": +"lodash@npm:^4.11.1, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.21, lodash@npm:^4.5.1": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 @@ -4754,6 +4881,13 @@ __metadata: languageName: node linkType: hard +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + "make-fetch-happen@npm:^8.0.14": version: 8.0.14 resolution: "make-fetch-happen@npm:8.0.14" @@ -5722,6 +5856,13 @@ __metadata: languageName: node linkType: hard +"pathval@npm:^1.1.1": + version: 1.1.1 + resolution: "pathval@npm:1.1.1" + checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.2, picomatch@npm:^2.2.3": version: 2.3.0 resolution: "picomatch@npm:2.3.0" @@ -6596,7 +6737,7 @@ __metadata: languageName: node linkType: hard -"source-map-support@npm:~0.5.19": +"source-map-support@npm:^0.5.17, source-map-support@npm:~0.5.19": version: 0.5.19 resolution: "source-map-support@npm:0.5.19" dependencies: @@ -6734,6 +6875,15 @@ __metadata: languageName: node linkType: hard +"std-mocks@npm:^1.0.1": + version: 1.0.1 + resolution: "std-mocks@npm:1.0.1" + dependencies: + lodash: ^4.11.1 + checksum: b7b97a39c77e373ea243443e195030ca0e41e0f7e8ba7908993511c4346dfdee0fb0d6edc0a72d2ed4ad3a26a1a4434d7dbde65629172452f3462745a8c8433a + languageName: node + linkType: hard + "stream-buffers@npm:^3.0.2": version: 3.0.2 resolution: "stream-buffers@npm:3.0.2" @@ -7202,6 +7352,40 @@ __metadata: languageName: node linkType: hard +"ts-node@npm:^10.0.0": + version: 10.0.0 + resolution: "ts-node@npm:10.0.0" + dependencies: + "@tsconfig/node10": ^1.0.7 + "@tsconfig/node12": ^1.0.7 + "@tsconfig/node14": ^1.0.0 + "@tsconfig/node16": ^1.0.1 + arg: ^4.1.0 + create-require: ^1.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + source-map-support: ^0.5.17 + yn: 3.1.1 + peerDependencies: + "@swc/core": ">=1.2.45" + "@swc/wasm": ">=1.2.45" + "@types/node": "*" + typescript: ">=2.7" + peerDependenciesMeta: + "@swc/core": + optional: true + "@swc/wasm": + optional: true + bin: + ts-node: dist/bin.js + ts-node-cwd: dist/bin-cwd.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: 96d633774e13eb90ad49d644f397e99f5da72818e36040bf5b6bd66d0ab369dbb4348e499193c0fa45071f8e9559bb7724174139389e56bb562db36a3842484e + languageName: node + linkType: hard + "tslib@npm:^1.13.0, tslib@npm:^1.8.1, tslib@npm:^1.9.0": version: 1.14.1 resolution: "tslib@npm:1.14.1" @@ -7257,6 +7441,13 @@ __metadata: languageName: node linkType: hard +"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": + version: 4.0.8 + resolution: "type-detect@npm:4.0.8" + checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 + languageName: node + linkType: hard + "type-fest@npm:^0.18.0": version: 0.18.1 resolution: "type-fest@npm:0.18.1" @@ -7750,6 +7941,13 @@ typescript@^4.3.3: languageName: node linkType: hard +"yn@npm:3.1.1": + version: 3.1.1 + resolution: "yn@npm:3.1.1" + checksum: 2c487b0e149e746ef48cda9f8bad10fc83693cd69d7f9dcd8be4214e985de33a29c9e24f3c0d6bcf2288427040a8947406ab27f7af67ee9456e6b84854f02dd6 + languageName: node + linkType: hard + "yocto-queue@npm:^0.1.0": version: 0.1.0 resolution: "yocto-queue@npm:0.1.0"