feature/IO-2769-Job-Totals-testing: Allow for both american and canadian capture + tests

This commit is contained in:
Dave Richer
2025-04-04 13:43:19 -04:00
parent add88659a4
commit 27a3932c08
4 changed files with 30 additions and 8 deletions

View File

@@ -1,7 +1,8 @@
import fs from "fs";
import path from "path";
import { describe, it, expect } from "vitest";
import { TotalsServerSide } from "../job-totals";
import { TotalsServerSide as TotalsServerSideCA } from "../job-totals"; // Canadian version (imex)
import { TotalsServerSide as TotalsServerSideUS } from "../job-totals-USA"; // US version (rome)
/**
* This function is used to replace the values in the object with their
@@ -48,7 +49,7 @@ describe("TotalsServerSide fixture tests", () => {
const fixturePath = path.join(fixturesDir, file);
const fixtureData = JSON.parse(fs.readFileSync(fixturePath, "utf8"));
const { input, output: expectedOutput } = fixtureData;
const { environment, input, output: expectedOutput } = fixtureData;
const req = {
body: {
@@ -58,7 +59,8 @@ describe("TotalsServerSide fixture tests", () => {
user: {}
};
const computedOutput = await TotalsServerSide(req, dummyRes);
const computedOutput =
environment === "us" ? await TotalsServerSideUS(req, dummyRes) : await TotalsServerSideCA(req, dummyRes);
const normalizedComputed = normalizeOutput(computedOutput);
const normalizedExpected = normalizeOutput(expectedOutput);