Skip to content

Commit

Permalink
Created tests for utils/array.
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-sth committed Oct 21, 2023
1 parent 44f53b1 commit cfa373d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/utils/array.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { arraysHaveSameValues } from "../../utils/array";

describe("arraysHaveSameValues", () => {
it("should return true for arrays with the same values", () => {
const arr1 = [1, 2, 3];
const arr2 = [3, 2, 1];
expect(arraysHaveSameValues(arr1, arr2)).toBe(true);
});

it("should return false for arrays with different lengths", () => {
const arr1 = [1, 2, 3];
const arr2 = [1, 2, 3, 4];
expect(arraysHaveSameValues(arr1, arr2)).toBe(false);
});

it("should return false for arrays with different values", () => {
const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];
expect(arraysHaveSameValues(arr1, arr2)).toBe(false);
});

it("should return true for empty arrays", () => {
const arr1: number[] = [];
const arr2: number[] = [];
expect(arraysHaveSameValues(arr1, arr2)).toBe(true);
});

it("should return true for arrays with duplicate values", () => {
const arr1 = [1, 2, 2, 3, 4];
const arr2 = [3, 2, 1, 4, 2];
expect(arraysHaveSameValues(arr1, arr2)).toBe(true);
});
});

0 comments on commit cfa373d

Please sign in to comment.