|
| 1 | +import { getRefinedChecks } from "./getRefinedChecks.ts"; |
| 2 | +import { CHECKS_LIST_NAMES } from "../../constants/checks"; |
| 3 | +import sample1 from "../../../cypress/fixtures/2ac5e9889aba461f5a54d320973d2574980d206b.json"; |
| 4 | +import sample2 from "../../../cypress/fixtures/077fd7d83d7d41695137c1af5b9be1d72250e69e.json"; |
| 5 | + |
| 6 | +describe("util: getRefinedChecks", () => { |
| 7 | + it("Should handle empty checks", () => { |
| 8 | + expect(getRefinedChecks([], [])).toEqual({ |
| 9 | + common: [], |
| 10 | + discrepancies: [], |
| 11 | + }); |
| 12 | + }); |
| 13 | + |
| 14 | + it("Should handle an empty check", () => { |
| 15 | + expect(getRefinedChecks(sample1.checks, [])).toEqual({ |
| 16 | + common: [], |
| 17 | + discrepancies: CHECKS_LIST_NAMES, |
| 18 | + }); |
| 19 | + |
| 20 | + expect(getRefinedChecks([], sample1.checks)).toEqual({ |
| 21 | + common: [], |
| 22 | + discrepancies: CHECKS_LIST_NAMES, |
| 23 | + }); |
| 24 | + }); |
| 25 | + |
| 26 | + it("Should generate a refined valid result", () => { |
| 27 | + expect(getRefinedChecks(sample1.checks, sample2.checks)).toEqual({ |
| 28 | + common: CHECKS_LIST_NAMES, |
| 29 | + discrepancies: [], |
| 30 | + }); |
| 31 | + }); |
| 32 | + |
| 33 | + it("Should handle discrepancies and provide a valid result", () => { |
| 34 | + const filteredList = sample1.checks.filter( |
| 35 | + (item) => item.name !== "Binary-Artifacts", |
| 36 | + ); |
| 37 | + expect(getRefinedChecks(filteredList, sample2.checks)).toEqual({ |
| 38 | + common: filteredList.map((item) => item.name), |
| 39 | + discrepancies: ["Binary-Artifacts"], |
| 40 | + }); |
| 41 | + }); |
| 42 | +}); |
0 commit comments