Skip to content

Commit

Permalink
Merge pull request #26 from erik-sth/Add-utils/array-testing-file-
Browse files Browse the repository at this point in the history
Created tests for utils/array.
  • Loading branch information
erik-sth authored Oct 21, 2023
2 parents 97da747 + 41958d9 commit aacdea8
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, 2];
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 aacdea8

Please sign in to comment.