Skip to content

Commit

Permalink
Rename compare content function #3900
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMehl committed Jan 31, 2025
1 parent a18326c commit 6971065
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions visualization/app/codeCharta/util/arrayHelper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addItemToArray, compareContent, removeItemFromArray } from "./arrayHelper"
import { addItemToArray, compareContentIgnoringOrder, removeItemFromArray } from "./arrayHelper"

function mutateObject(object: Record<string, number>) {
object.x = 10_000
Expand Down Expand Up @@ -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 },
Expand All @@ -52,7 +52,7 @@ describe("arrayHelper", () => {
{ x: 3, y: 4 }
]

const result = compareContent(array1, array2)
const result = compareContentIgnoringOrder(array1, array2)

expect(result).toBe(true)
})
Expand All @@ -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)
})
Expand All @@ -76,7 +76,7 @@ describe("arrayHelper", () => {
{ x: 3, y: 4 }
]

const result = compareContent(array1, array2)
const result = compareContentIgnoringOrder(array1, array2)

expect(result).toBe(true)
})
Expand All @@ -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)
Expand All @@ -99,7 +99,7 @@ describe("arrayHelper", () => {
const array1 = []
const array2 = []

const result = compareContent(array1, array2)
const result = compareContentIgnoringOrder(array1, array2)

expect(result).toBe(true)
})
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion visualization/app/codeCharta/util/arrayHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function addItemsToArray<T>(array: T[], items: T[]): T[] {
return newArray
}

export function compareContent<T>(array1: T[], array2: T[]): boolean {
export function compareContentIgnoringOrder<T>(array1: T[], array2: T[]): boolean {
if (array1.length !== array2.length) {
return false
}
Expand Down

0 comments on commit 6971065

Please sign in to comment.