-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidations.test.ts
40 lines (36 loc) · 1016 Bytes
/
validations.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { describe, expect, test } from "vitest";
import { isBodyWithReplies, isRepositorySettings } from "./validations.js";
describe("isBodyWithReplies", () => {
test.each([
["", false],
[[], false],
[null, false],
[undefined, false],
[{}, false],
[{ replies: null }, false],
[{ replies: undefined }, false],
[{ replies: [] }, true],
[{ replies: [{}] }, false],
[{ replies: [{ body: "" }] }, false],
[{ replies: [{ name: "" }] }, false],
[{ replies: [{ body: "", name: "" }] }, true],
])("%s is %s", (input, expected) => {
const actual = isBodyWithReplies(input);
expect(actual).toBe(expected);
});
});
describe("isRepositoryDetails", () => {
test.each([
["", false],
[[], false],
[null, false],
[undefined, false],
[{}, false],
[{ default_branch: null }, false],
[{ default_branch: undefined }, false],
[{ default_branch: "" }, true],
])("%s is %s", (input, expected) => {
const actual = isRepositorySettings(input);
expect(actual).toBe(expected);
});
});