mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-23 07:34:07 -05:00
* Initial * Progress * Fix * Progress * Notifications list page * BADGE_MANAGER_ADDED * Mark as seen initial * Split tables * Progress * Fix styles * Push notifs initial * Progress * Rename * Routines * Progress * Add e2e tests * Done? * Try updating actions * Consistency * Dep fix * A couple fixes
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { diff } from "./arrays";
|
|
|
|
describe("diff", () => {
|
|
it("should return elements in arr2 but not in arr1", () => {
|
|
const arr1 = [1, 2, 3];
|
|
const arr2 = [2, 3, 4, 4];
|
|
const result = diff(arr1, arr2);
|
|
expect(result).toEqual([4, 4]);
|
|
});
|
|
|
|
it("should return an empty array if arr2 is empty", () => {
|
|
const arr1 = [1, 2, 3];
|
|
const arr2: number[] = [];
|
|
const result = diff(arr1, arr2);
|
|
expect(result).toEqual([]);
|
|
});
|
|
|
|
it("should return all elements of arr2 if arr1 is empty", () => {
|
|
const arr1: number[] = [];
|
|
const arr2 = [1, 2, 3];
|
|
const result = diff(arr1, arr2);
|
|
expect(result).toEqual([1, 2, 3]);
|
|
});
|
|
|
|
it("should handle arrays with duplicate elements", () => {
|
|
const arr1 = [1, 2, 2, 3];
|
|
const arr2 = [2, 2, 3, 3, 4];
|
|
const result = diff(arr1, arr2);
|
|
expect(result).toEqual([3, 4]);
|
|
});
|
|
|
|
it("should return an empty array if both arrays are the same", () => {
|
|
const arr1 = [1, 2, 3];
|
|
const arr2 = [1, 2, 3];
|
|
const result = diff(arr1, arr2);
|
|
expect(result).toEqual([]);
|
|
});
|
|
});
|