Skip to content

Commit

Permalink
chore(be): add toArray tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Oct 4, 2024
1 parent e02d16e commit ae014fc
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions backend-nest/src/utils/array.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { toArray } from "src/utils/array.utils";

describe("toArray", () => {
it("should convert to array", () => {
expect(toArray("string value")).toStrictEqual(["string value"]);
});

it("should leave nested arrays same", () => {
expect(toArray([["string value"]])).toStrictEqual([["string value"]]);
});

it("should not change array", () => {
expect(
toArray([
"string value",
undefined,
null,
1,
69,
420,
-Infinity,
{
key: "value",
},
]),
).toStrictEqual([
"string value",
undefined,
null,
1,
69,
420,
-Infinity,
{
key: "value",
},
]);
});

it("should work with object", () => {
expect(toArray({})).toStrictEqual([{}]);
});
});

0 comments on commit ae014fc

Please sign in to comment.