Skip to content

Commit

Permalink
test: added specs for getRefinedChecks function
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon committed Oct 28, 2023
1 parent a2728c0 commit 2fdc980
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/utils/comparator/getRefinedChecks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { getRefinedChecks } from "./getRefinedChecks.ts";
import { CHECKS_LIST_NAMES } from "../../constants/checks";
import sample1 from "../../../cypress/fixtures/2ac5e9889aba461f5a54d320973d2574980d206b.json";
import sample2 from "../../../cypress/fixtures/077fd7d83d7d41695137c1af5b9be1d72250e69e.json";

describe("util: getRefinedChecks", () => {
it("Should handle empty checks", () => {
expect(getRefinedChecks([], [])).toEqual({
common: [],
discrepancies: [],
});
});

it("Should handle an empty check", () => {
expect(getRefinedChecks(sample1.checks, [])).toEqual({
common: [],
discrepancies: CHECKS_LIST_NAMES,
});

expect(getRefinedChecks([], sample1.checks)).toEqual({
common: [],
discrepancies: CHECKS_LIST_NAMES,
});
});

it("Should generate a refined valid result", () => {
expect(getRefinedChecks(sample1.checks, sample2.checks)).toEqual({
common: CHECKS_LIST_NAMES,
discrepancies: [],
});
});

it("Should handle discrepancies and provide a valid result", () => {
const filteredList = sample1.checks.filter(
(item) => item.name !== "Binary-Artifacts",
);
expect(getRefinedChecks(filteredList, sample2.checks)).toEqual({
common: filteredList.map((item) => item.name),
discrepancies: ["Binary-Artifacts"],
});
});
});
File renamed without changes.

0 comments on commit 2fdc980

Please sign in to comment.