@@ -6,138 +6,38 @@ import { Dispatcher } from '../Dispatcher'
6
6
import { CheckState } from '../types'
7
7
import { MilestoneCheck } from './MilestoneCheck'
8
8
9
+ const prEvents = [ 'pull_request' , 'pull_request_target' ]
10
+ const prActions = [ 'opened' , 'reopened' , 'ready_for_review' , 'synchronize' , 'labeled' , 'unlabeled' ]
11
+
12
+ const prTestCases = prEvents
13
+ . flatMap ( ( event ) => {
14
+ return prActions . map ( ( action ) => ( {
15
+ eventName : event ,
16
+ action : action ,
17
+ } ) )
18
+ } )
19
+ . flatMap ( ( tc ) => [
20
+ {
21
+ testCaseName : 'without milestone set' ,
22
+ eventName : tc . eventName ,
23
+ action : tc . action ,
24
+ checkState : CheckState . Failure ,
25
+ description : 'Failed' ,
26
+ pull_request_payload : { } ,
27
+ } ,
28
+ {
29
+ testCaseName : 'with milestone set' ,
30
+ eventName : tc . eventName ,
31
+ action : tc . action ,
32
+ checkState : CheckState . Success ,
33
+ description : 'Milestone set' ,
34
+ pull_request_payload : { milestone : { } } ,
35
+ } ,
36
+ ] )
37
+
9
38
describe ( 'MilestoneCheck' , ( ) => {
10
39
describe ( 'Pull Requests' , ( ) => {
11
- test . each ( [
12
- {
13
- testCaseName : 'without milestone set' ,
14
- eventName : 'pull_request' ,
15
- action : 'opened' ,
16
- checkState : CheckState . Failure ,
17
- description : 'Failed' ,
18
- pull_request_payload : { } ,
19
- } ,
20
- {
21
- testCaseName : 'without milestone set' ,
22
- eventName : 'pull_request' ,
23
- action : 'reopened' ,
24
- checkState : CheckState . Failure ,
25
- description : 'Failed' ,
26
- pull_request_payload : { } ,
27
- } ,
28
- {
29
- testCaseName : 'without milestone set' ,
30
- eventName : 'pull_request' ,
31
- action : 'synchronize' ,
32
- checkState : CheckState . Failure ,
33
- description : 'Failed' ,
34
- pull_request_payload : { } ,
35
- } ,
36
- {
37
- testCaseName : 'without milestone set' ,
38
- eventName : 'pull_request' ,
39
- action : 'ready_for_review' ,
40
- checkState : CheckState . Failure ,
41
- description : 'Failed' ,
42
- pull_request_payload : { } ,
43
- } ,
44
- {
45
- testCaseName : 'without milestone set' ,
46
- eventName : 'pull_request_target' ,
47
- action : 'opened' ,
48
- checkState : CheckState . Failure ,
49
- description : 'Failed' ,
50
- pull_request_payload : { } ,
51
- } ,
52
- {
53
- testCaseName : 'without milestone set' ,
54
- eventName : 'pull_request_target' ,
55
- action : 'reopened' ,
56
- checkState : CheckState . Failure ,
57
- description : 'Failed' ,
58
- pull_request_payload : { } ,
59
- } ,
60
- {
61
- testCaseName : 'without milestone set' ,
62
- eventName : 'pull_request_target' ,
63
- action : 'ready_for_review' ,
64
- checkState : CheckState . Failure ,
65
- description : 'Failed' ,
66
- pull_request_payload : { } ,
67
- } ,
68
- {
69
- testCaseName : 'without milestone set' ,
70
- eventName : 'pull_request_target' ,
71
- action : 'synchronize' ,
72
- checkState : CheckState . Failure ,
73
- description : 'Failed' ,
74
- pull_request_payload : { } ,
75
- } ,
76
- {
77
- testCaseName : 'with milestone set' ,
78
- eventName : 'pull_request' ,
79
- action : 'opened' ,
80
- checkState : CheckState . Success ,
81
- description : 'Milestone set' ,
82
- pull_request_payload : { milestone : { } } ,
83
- } ,
84
- {
85
- testCaseName : 'with milestone set' ,
86
- eventName : 'pull_request' ,
87
- action : 'reopened' ,
88
- checkState : CheckState . Success ,
89
- description : 'Milestone set' ,
90
- pull_request_payload : { milestone : { } } ,
91
- } ,
92
- {
93
- testCaseName : 'with milestone set' ,
94
- eventName : 'pull_request' ,
95
- action : 'ready_for_review' ,
96
- checkState : CheckState . Success ,
97
- description : 'Milestone set' ,
98
- pull_request_payload : { milestone : { } } ,
99
- } ,
100
- {
101
- testCaseName : 'with milestone set' ,
102
- eventName : 'pull_request' ,
103
- action : 'synchronize' ,
104
- checkState : CheckState . Success ,
105
- description : 'Milestone set' ,
106
- pull_request_payload : { milestone : { } } ,
107
- } ,
108
- {
109
- testCaseName : 'with milestone set' ,
110
- eventName : 'pull_request_target' ,
111
- action : 'opened' ,
112
- checkState : CheckState . Success ,
113
- description : 'Milestone set' ,
114
- pull_request_payload : { milestone : { } } ,
115
- } ,
116
- {
117
- testCaseName : 'with milestone set' ,
118
- eventName : 'pull_request_target' ,
119
- action : 'reopened' ,
120
- checkState : CheckState . Success ,
121
- description : 'Milestone set' ,
122
- pull_request_payload : { milestone : { } } ,
123
- } ,
124
- {
125
- testCaseName : 'with milestone set' ,
126
- eventName : 'pull_request_target' ,
127
- action : 'ready_for_review' ,
128
- checkState : CheckState . Success ,
129
- description : 'Milestone set' ,
130
- pull_request_payload : { milestone : { } } ,
131
- } ,
132
- {
133
- testCaseName : 'with milestone set' ,
134
- eventName : 'pull_request_target' ,
135
- action : 'synchronize' ,
136
- checkState : CheckState . Success ,
137
- description : 'Milestone set' ,
138
- pull_request_payload : { milestone : { } } ,
139
- } ,
140
- ] ) (
40
+ test . each ( prTestCases ) (
141
41
'$eventName - $action - $testCaseName - Should create status $checkState' ,
142
42
async ( { eventName, action, checkState, description, pull_request_payload } ) => {
143
43
const createStatusMock = jest . fn ( )
0 commit comments