forked from thomaseizinger/create-pull-request
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetInputs.test.ts
More file actions
78 lines (61 loc) · 1.86 KB
/
getInputs.test.ts
File metadata and controls
78 lines (61 loc) · 1.86 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { morph } from "mock-env";
import { getInputs } from "../src/getInputs";
const MANDATORY_INPUTS = {
INPUT_HEAD: "refs/heads/feature/test",
INPUT_TITLE: "My test pull request",
GITHUB_REPOSITORY: "foo/bar"
};
it("should default base to master", function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS
});
expect(inputs).toHaveProperty("base", "master");
});
it('should parse "false" for draft as false', function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_DRAFT: "false"
});
expect(inputs).toHaveProperty("draft", false);
});
it('should parse "true" for draft as true', function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_DRAFT: "true"
});
expect(inputs).toHaveProperty("draft", true);
});
it("should include body if given", function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_BODY: "Fixes #42"
});
expect(inputs).toHaveProperty("body", "Fixes #42");
});
it("should parse owner and repo", function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS
});
expect(inputs).toHaveProperty("owner", "foo");
expect(inputs).toHaveProperty("repo", "bar");
});
it("should default to empty list of reviewers", function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS
});
expect(inputs).toHaveProperty("reviewers", []);
});
it("should split reviewers by comma", function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_REVIEWERS: "thomaseizinger,bonomat"
});
expect(inputs).toHaveProperty("reviewers", ["thomaseizinger", "bonomat"]);
});
it("should trim reviewer names", function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_REVIEWERS: "d4nte, bonomat, luckysori"
});
expect(inputs).toHaveProperty("reviewers", ["d4nte", "bonomat", "luckysori"]);
});