-
Notifications
You must be signed in to change notification settings - Fork 22
/
getInputs.test.ts
114 lines (89 loc) · 2.75 KB
/
getInputs.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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 parse owner and repo for input repository', function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_REPOSITORY: 'my/repository',
});
expect(inputs).toHaveProperty('owner', 'my');
expect(inputs).toHaveProperty('repo', 'repository');
});
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']);
});
it('should default to empty list of labels', function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
});
expect(inputs).toHaveProperty('labels', []);
});
it('should split labels by comma', function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_LABELS: 'label1,label2',
});
expect(inputs).toHaveProperty('labels', ['label1', 'label2']);
});
it('should trim labels', function() {
const inputs = morph(getInputs, {
...MANDATORY_INPUTS,
INPUT_LABELS: 'label1, label2, label3',
});
expect(inputs).toHaveProperty('labels', ['label1', 'label2', 'label3']);
});