test: use vitest instead of jest

This commit is contained in:
Johannes Loher 2022-08-22 22:05:14 +02:00
parent 7d953d5a50
commit bb6d22d14a
12 changed files with 530 additions and 2288 deletions

View file

@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { describe, expect, it } from "vitest";
import { calculateSpellPrice } from "../../../src/item/spell/calculate-spell-price";
import type { CooldownDuration, DS4SpellDataSourceData } from "../../../src/item/spell/spell-data-source";
@ -40,6 +42,7 @@ type TestCase = {
type CombinedTestCase = {
minimumLevels: DS4SpellDataSourceData["minimumLevels"];
expected: number | null;
description: string;
};
const testCases: Record<keyof DS4SpellDataSourceData["minimumLevels"], TestCase[]> = {
@ -134,13 +137,16 @@ function buildCombinedTestCases(): CombinedTestCase[] {
wizardTestCase.expected ?? Infinity,
)
: null;
const minimumLevels = {
healer: healerTestCase.minimumLevel,
sorcerer: sorcererTestCase.minimumLevel,
wizard: wizardTestCase.minimumLevel,
};
const description = JSON.stringify(minimumLevels);
combinedTestCases.push({
minimumLevels: {
healer: healerTestCase.minimumLevel,
sorcerer: sorcererTestCase.minimumLevel,
wizard: wizardTestCase.minimumLevel,
},
minimumLevels,
expected,
description,
});
}
}
@ -151,12 +157,15 @@ function buildCombinedTestCases(): CombinedTestCase[] {
for (const spellCasterClass of ["healer", "sorcerer", "wizard"] as const) {
for (const testCase of testCases[spellCasterClass].filter(isRelevantSingleTestCase)) {
const minimumLevels = {
...defaultData.minimumLevels,
[spellCasterClass]: testCase.minimumLevel,
};
const description = JSON.stringify(minimumLevels);
combinedTestCases.push({
minimumLevels: {
...defaultData.minimumLevels,
[spellCasterClass]: testCase.minimumLevel,
},
minimumLevels,
expected: testCase.expected,
description,
});
}
}
@ -185,7 +194,7 @@ describe("calculateSpellPrice", () => {
};
it.each(buildCombinedTestCases())(
`returns ${factor} × $expected if the minimum leves are $minimumLevels`,
`returns ${factor} × $expected if the minimum leves are $description`,
({ minimumLevels, expected }) => {
// given
const data: DS4SpellDataSourceData = {