build: add jest, tests
This commit is contained in:
29
tests/removeFromArrayByKeyValue.test.ts
Normal file
29
tests/removeFromArrayByKeyValue.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { expect, test } from "@jest/globals";
|
||||
import { removeFromArrayByKeyValue } from "../src";
|
||||
|
||||
test("removes an object from an array by key-value object", () => {
|
||||
expect(
|
||||
removeFromArrayByKeyValue(
|
||||
[
|
||||
{ a: "1", b: "0" },
|
||||
{ a: "2", b: "0" },
|
||||
{ a: "3", b: "0" },
|
||||
],
|
||||
{ a: "3" },
|
||||
),
|
||||
).toMatchObject([
|
||||
{ a: "1", b: "0" },
|
||||
{ a: "2", b: "0" },
|
||||
]);
|
||||
|
||||
expect(
|
||||
removeFromArrayByKeyValue(
|
||||
[
|
||||
{ a: "1", b: "0" },
|
||||
{ a: "2", b: "0" },
|
||||
{ a: "3", b: "0" },
|
||||
],
|
||||
{ b: "0" },
|
||||
),
|
||||
).toMatchObject([]);
|
||||
});
|
||||
Reference in New Issue
Block a user