Skip to content

Commit

Permalink
chore: added new tests for both transformer versions - with status co…
Browse files Browse the repository at this point in the history
…de and without status code
  • Loading branch information
mihir-4116 committed Oct 5, 2023
1 parent b40add8 commit 4cfc660
Show file tree
Hide file tree
Showing 8 changed files with 1,662 additions and 1,284 deletions.
29 changes: 16 additions & 13 deletions test/__tests__/braze.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,29 @@ inputData.forEach((input, index) => {
});
});
// Router Test Data
const inputRouterDataFile = fs.readFileSync(
path.resolve(__dirname, `./data/${integration}_router_input.json`)
const routerTestDataFile = fs.readFileSync(
path.resolve(__dirname, `./data/${integration}_router.json`)
);
const outputRouterDataFile = fs.readFileSync(
path.resolve(__dirname, `./data/${integration}_router_output.json`)
);
const inputRouterData = JSON.parse(inputRouterDataFile);
const expectedRouterData = JSON.parse(outputRouterDataFile);
const routerTestData = JSON.parse(routerTestDataFile);
const { simpleRouterTestData, dedupEnabledRouterTestData } = routerTestData;

describe(`${name} Tests`, () => {
describe("Simple Router Tests", () => {
it("Payload", async () => {
const routerOutput = await transformer.processRouterDest(inputRouterData.simpleRouterRequests);
expect(routerOutput).toEqual(expectedRouterData.simpleRouterResponse);
simpleRouterTestData.forEach((dataPoint, index) => {
it(`${index}. ${integration} - ${dataPoint.description}`, async () => {
const output = await transformer.processRouterDest(dataPoint.input);
expect(output).toEqual(dataPoint.output);
});
});
});
describe("Dedupenabled Router Tests", () => {
it("Payload", async () => {
const routerOutput = await transformer.processRouterDest(inputRouterData.dedupEnabledRouterRequests, { features: { [FEATURE_FILTER_CODE]: true } });
expect(routerOutput).toEqual(expectedRouterData.dedupEnabledRouterResponse);
dedupEnabledRouterTestData.forEach((dataPoint, index) => {
it(`${index}. ${integration} - ${dataPoint.description}`, async () => {
const oldTransformerOutput = await transformer.processRouterDest(dataPoint.input);
const newTransformerOutput = await transformer.processRouterDest(dataPoint.input, { features: { [FEATURE_FILTER_CODE]: true } });
expect(oldTransformerOutput).toEqual(dataPoint.oldTransformerOutput);
expect(newTransformerOutput).toEqual(dataPoint.newTransformerOutput);
});
});
});
});
Loading

0 comments on commit 4cfc660

Please sign in to comment.