From 526d387c0343396ac83afd7db56e56ade8216ae5 Mon Sep 17 00:00:00 2001 From: Benedikt Mehl Date: Fri, 31 Jan 2025 13:26:51 +0100 Subject: [PATCH] Rename compare content function #3900 --- .../visibleFileStates.selector.ts | 4 ++-- .../app/codeCharta/util/arrayHelper.spec.ts | 20 +++++++++---------- .../app/codeCharta/util/arrayHelper.ts | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/visualization/app/codeCharta/state/selectors/visibleFileStates/visibleFileStates.selector.ts b/visualization/app/codeCharta/state/selectors/visibleFileStates/visibleFileStates.selector.ts index cd644186df..442d73e227 100644 --- a/visualization/app/codeCharta/state/selectors/visibleFileStates/visibleFileStates.selector.ts +++ b/visualization/app/codeCharta/state/selectors/visibleFileStates/visibleFileStates.selector.ts @@ -2,7 +2,7 @@ import { FileSelectionState, FileState } from "../../../model/files/files" import { createSelectorFactory, defaultMemoize } from "@ngrx/store" import { filesSelector } from "../../store/files/files.selector" import { getVisibleFileStates, isDeltaState } from "../../../model/files/files.helper" -import { compareContent } from "../../../util/arrayHelper" +import { compareContentIgnoringOrder } from "../../../util/arrayHelper" export function _onlyVisibleFilesMatterComparer(fileStates1: FileState[], fileStates2: FileState[]): boolean { if (fileStates1 === fileStates2) { @@ -28,7 +28,7 @@ export function _onlyVisibleFilesMatterComparer(fileStates1: FileState[], fileSt return false } - return compareContent(visibleFileChecksums1, visibleFileChecksum2) + return compareContentIgnoringOrder(visibleFileChecksums1, visibleFileChecksum2) } function compareDeltaState(fileStates1: FileState[], fileStates2: FileState[]): boolean { diff --git a/visualization/app/codeCharta/util/arrayHelper.spec.ts b/visualization/app/codeCharta/util/arrayHelper.spec.ts index eb7362488d..dbb4b26915 100644 --- a/visualization/app/codeCharta/util/arrayHelper.spec.ts +++ b/visualization/app/codeCharta/util/arrayHelper.spec.ts @@ -1,4 +1,4 @@ -import { addItemToArray, compareContent, removeItemFromArray } from "./arrayHelper" +import { addItemToArray, compareContentIgnoringOrder, removeItemFromArray } from "./arrayHelper" function mutateObject(object: Record) { object.x = 10_000 @@ -41,7 +41,7 @@ describe("arrayHelper", () => { }) }) - describe("compareContent", () => { + describe("compareContentIgnoringOrder", () => { it("should return true for arrays with the same contents", () => { const array1 = [ { x: 1, y: 2 }, @@ -52,7 +52,7 @@ describe("arrayHelper", () => { { x: 3, y: 4 } ] - const result = compareContent(array1, array2) + const result = compareContentIgnoringOrder(array1, array2) expect(result).toBe(true) }) @@ -61,7 +61,7 @@ describe("arrayHelper", () => { const array1 = [{ x: 1, y: 2 }] const array2 = [{ x: 3, y: 4 }] - const result = compareContent(array1, array2) + const result = compareContentIgnoringOrder(array1, array2) expect(result).toBe(false) }) @@ -76,7 +76,7 @@ describe("arrayHelper", () => { { x: 3, y: 4 } ] - const result = compareContent(array1, array2) + const result = compareContentIgnoringOrder(array1, array2) expect(result).toBe(true) }) @@ -88,8 +88,8 @@ describe("arrayHelper", () => { { x: 3, y: 4 } ] - const result1 = compareContent(array1, array2) - const result2 = compareContent(array2, array1) + const result1 = compareContentIgnoringOrder(array1, array2) + const result2 = compareContentIgnoringOrder(array2, array1) expect(result1).toBe(false) expect(result2).toBe(false) @@ -99,7 +99,7 @@ describe("arrayHelper", () => { const array1 = [] const array2 = [] - const result = compareContent(array1, array2) + const result = compareContentIgnoringOrder(array1, array2) expect(result).toBe(true) }) @@ -116,8 +116,8 @@ describe("arrayHelper", () => { { x: 1, y: 3 } ] - const result1 = compareContent(array1, array2) - const result2 = compareContent(array2, array1) + const result1 = compareContentIgnoringOrder(array1, array2) + const result2 = compareContentIgnoringOrder(array2, array1) expect(result1).toBe(false) expect(result2).toBe(false) diff --git a/visualization/app/codeCharta/util/arrayHelper.ts b/visualization/app/codeCharta/util/arrayHelper.ts index 1e92abe73b..9322a3c883 100644 --- a/visualization/app/codeCharta/util/arrayHelper.ts +++ b/visualization/app/codeCharta/util/arrayHelper.ts @@ -26,7 +26,7 @@ export function addItemsToArray(array: T[], items: T[]): T[] { return newArray } -export function compareContent(array1: T[], array2: T[]): boolean { +export function compareContentIgnoringOrder(array1: T[], array2: T[]): boolean { if (array1.length !== array2.length) { return false }