Minor cleanup of tests
This commit is contained in:
parent
0614f14ad6
commit
7693aae4bf
1 changed files with 14 additions and 30 deletions
|
@ -6,7 +6,7 @@ import {
|
||||||
} from "features/conversion";
|
} from "features/conversion";
|
||||||
import { createResource, Resource } from "features/resources/resource";
|
import { createResource, Resource } from "features/resources/resource";
|
||||||
import { GenericFormula } from "game/formulas/types";
|
import { GenericFormula } from "game/formulas/types";
|
||||||
import { createLayer } from "game/layers";
|
import { createLayer, GenericLayer } from "game/layers";
|
||||||
import Decimal from "util/bignum";
|
import Decimal from "util/bignum";
|
||||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
import { ref, unref } from "vue";
|
import { ref, unref } from "vue";
|
||||||
|
@ -450,53 +450,37 @@ describe("Passive generation", () => {
|
||||||
let baseResource: Resource;
|
let baseResource: Resource;
|
||||||
let gainResource: Resource;
|
let gainResource: Resource;
|
||||||
let formula: (x: GenericFormula) => GenericFormula;
|
let formula: (x: GenericFormula) => GenericFormula;
|
||||||
|
let conversion: GenericConversion;
|
||||||
|
let layer: GenericLayer;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
baseResource = createResource(ref(40));
|
baseResource = createResource(ref(10));
|
||||||
gainResource = createResource(ref(1));
|
gainResource = createResource(ref(1));
|
||||||
formula = x => x.div(10).sqrt();
|
formula = x => x.div(10).sqrt();
|
||||||
});
|
conversion = createCumulativeConversion(() => ({
|
||||||
test("Rate is 0", () => {
|
|
||||||
const conversion = createCumulativeConversion(() => ({
|
|
||||||
baseResource,
|
baseResource,
|
||||||
gainResource,
|
gainResource,
|
||||||
formula
|
formula
|
||||||
}));
|
}));
|
||||||
const layer = createLayer("dummy", () => ({ display: "" }));
|
layer = createLayer("dummy", () => ({ display: "" }));
|
||||||
|
});
|
||||||
|
test("Rate is 0", () => {
|
||||||
setupPassiveGeneration(layer, conversion, 0);
|
setupPassiveGeneration(layer, conversion, 0);
|
||||||
layer.emit("preUpdate", 100);
|
layer.emit("preUpdate", 1);
|
||||||
expect(gainResource.value).compare_tolerance(1);
|
expect(gainResource.value).compare_tolerance(1);
|
||||||
});
|
});
|
||||||
test("Rate is 1", () => {
|
test("Rate is 1", () => {
|
||||||
const conversion = createCumulativeConversion(() => ({
|
|
||||||
baseResource,
|
|
||||||
gainResource,
|
|
||||||
formula
|
|
||||||
}));
|
|
||||||
const layer = createLayer("dummy", () => ({ display: "" }));
|
|
||||||
setupPassiveGeneration(layer, conversion);
|
setupPassiveGeneration(layer, conversion);
|
||||||
layer.emit("preUpdate", 100);
|
layer.emit("preUpdate", 1);
|
||||||
expect(gainResource.value).compare_tolerance(201);
|
expect(gainResource.value).compare_tolerance(2);
|
||||||
})
|
})
|
||||||
test("Rate is 100", () => {
|
test("Rate is 100", () => {
|
||||||
const conversion = createCumulativeConversion(() => ({
|
|
||||||
baseResource,
|
|
||||||
gainResource,
|
|
||||||
formula
|
|
||||||
}));
|
|
||||||
const layer = createLayer("dummy", () => ({ display: "" }));
|
|
||||||
setupPassiveGeneration(layer, conversion, () => 100);
|
setupPassiveGeneration(layer, conversion, () => 100);
|
||||||
layer.emit("preUpdate", 100);
|
layer.emit("preUpdate", 1);
|
||||||
expect(gainResource.value).compare_tolerance(20001);
|
expect(gainResource.value).compare_tolerance(101);
|
||||||
})
|
})
|
||||||
test("Obeys cap", () => {
|
test("Obeys cap", () => {
|
||||||
const conversion = createCumulativeConversion(() => ({
|
|
||||||
baseResource,
|
|
||||||
gainResource,
|
|
||||||
formula
|
|
||||||
}));
|
|
||||||
const layer = createLayer("dummy", () => ({ display: "" }));
|
|
||||||
setupPassiveGeneration(layer, conversion, 100, () => 100);
|
setupPassiveGeneration(layer, conversion, 100, () => 100);
|
||||||
layer.emit("preUpdate", 100);
|
layer.emit("preUpdate", 1);
|
||||||
expect(gainResource.value).compare_tolerance(100);
|
expect(gainResource.value).compare_tolerance(100);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue