Switch to jest
This commit is contained in:
parent
b6bb22dc81
commit
af07168c5b
11 changed files with 2534 additions and 8248 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -17,6 +17,7 @@ dist
|
|||
|
||||
# Junit results
|
||||
results.xml
|
||||
junit.xml
|
||||
|
||||
# yarn
|
||||
.yarn/*
|
||||
|
|
|
@ -29,7 +29,7 @@ test:
|
|||
when: always
|
||||
reports:
|
||||
junit:
|
||||
- results.xml
|
||||
- junit.xml
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
|
9
jest.config.js
Normal file
9
jest.config.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
tsconfig: "<rootDir>/spec/tsconfig.spec.json",
|
||||
},
|
||||
},
|
||||
};
|
8133
package-lock.json
generated
8133
package-lock.json
generated
File diff suppressed because it is too large
Load diff
11
package.json
11
package.json
|
@ -39,13 +39,13 @@
|
|||
"updateManifest": "gulp updateManifest",
|
||||
"lint": "eslint 'src/**/*.ts' --cache",
|
||||
"lint:fix": "eslint 'src/**/*.ts' --cache --fix",
|
||||
"test": "ts-node ./node_modules/jasmine/bin/jasmine",
|
||||
"test:ci": "ts-node ./node_modules/jasmine-xml-reporter/bin/jasmine --junitreport",
|
||||
"test": "jest",
|
||||
"test:ci": "jest --ci --reporters=default --reporters=jest-junit",
|
||||
"format": "prettier --write 'src/**/*.(ts|json|scss)'"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.6",
|
||||
"@types/jasmine": "^3.6.3",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@typescript-eslint/eslint-plugin": "^4.14.2",
|
||||
"@typescript-eslint/parser": "^4.14.2",
|
||||
"archiver": "^5.2.0",
|
||||
|
@ -61,12 +61,13 @@
|
|||
"gulp-sass": "^4.1.0",
|
||||
"gulp-typescript": "^6.0.0-alpha.1",
|
||||
"husky": "^4.3.8",
|
||||
"jasmine": "^3.6.4",
|
||||
"jasmine-xml-reporter": "^1.2.1",
|
||||
"jest": "^26.6.3",
|
||||
"jest-junit": "^12.0.0",
|
||||
"json-stringify-pretty-compact": "^2.0.0",
|
||||
"lint-staged": "^10.5.4",
|
||||
"prettier": "^2.2.1",
|
||||
"sass": "^1.32.6",
|
||||
"ts-jest": "^26.5.1",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.1.3",
|
||||
"yargs": "^16.2.0"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import "jasmine";
|
||||
import * as fs from "fs-extra";
|
||||
import * as path from "path";
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
import { rollCheckMultipleDice, rollCheckSingleDie } from "../../../src/module/rolls/roll-executor";
|
||||
|
||||
import "jasmine";
|
||||
import { RollResult, RollResultStatus } from "../../../src/module/rolls/roll-data";
|
||||
import { RollResult, RollResultStatus } from "../../src/module/rolls/roll-data";
|
||||
import { rollCheckMultipleDice, rollCheckSingleDie } from "../../src/module/rolls/roll-executor";
|
||||
|
||||
describe("DS4 Rolls with one die and no modifications.", () => {
|
||||
it("Should do a regular success roll.", () => {
|
|
@ -1,24 +1,23 @@
|
|||
import "jasmine";
|
||||
import { isDiceSwapNecessary } from "../../../src/module/rolls/roll-utils";
|
||||
import { isDiceSwapNecessary } from "../../src/module/rolls/roll-utils";
|
||||
|
||||
describe("Utility function testing if dice swap is necessary", () => {
|
||||
it("Should not swap if all dice are crit successes.", () => {
|
||||
expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalse();
|
||||
expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("Should not swap if no die is crit success.", () => {
|
||||
expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalse();
|
||||
expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("Should not swap if all dice are already in use", () => {
|
||||
expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalse();
|
||||
expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("Should not swap if result does not get any better", () => {
|
||||
expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalse();
|
||||
expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("Should swap if result does get better", () => {
|
||||
expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTrue();
|
||||
expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": ["**/*[sS]pec.ts"],
|
||||
"helpers": ["helpers/**/*.ts"],
|
||||
"stopSpecOnExpectationFailure": false,
|
||||
"random": true
|
||||
}
|
7
spec/tsconfig.spec.json
Normal file
7
spec/tsconfig.spec.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": ["foundry-vtt-types", "jest"]
|
||||
},
|
||||
"include": ["src", "./"]
|
||||
}
|
Loading…
Reference in a new issue