@@ -17,6 +17,16 @@ test('should fail with unexpected author', async () => {
17
17
expect ( filter . status ) . toBe ( 'fail' )
18
18
} )
19
19
20
+ test ( 'should fail with unexpected author one_of author' , async ( ) => {
21
+ const author = new Author ( )
22
+ const settings = {
23
+ do : 'author' ,
24
+ one_of : [ otherAuthorName ]
25
+ }
26
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
27
+ expect ( filter . status ) . toBe ( 'fail' )
28
+ } )
29
+
20
30
test ( 'should pass with expected author' , async ( ) => {
21
31
const author = new Author ( )
22
32
const settings = {
@@ -29,6 +39,16 @@ test('should pass with expected author', async () => {
29
39
expect ( filter . status ) . toBe ( 'pass' )
30
40
} )
31
41
42
+ test ( 'should pass with one_of author' , async ( ) => {
43
+ const author = new Author ( )
44
+ const settings = {
45
+ do : 'author' ,
46
+ one_of : [ authorName ]
47
+ }
48
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
49
+ expect ( filter . status ) . toBe ( 'pass' )
50
+ } )
51
+
32
52
test ( 'should fail with excluded author' , async ( ) => {
33
53
const author = new Author ( )
34
54
const settings = {
@@ -41,13 +61,21 @@ test('should fail with excluded author', async () => {
41
61
expect ( filter . status ) . toBe ( 'fail' )
42
62
} )
43
63
44
- test ( 'should pass with excluded author' , async ( ) => {
64
+ test ( 'should fail with none_of author' , async ( ) => {
45
65
const author = new Author ( )
46
66
const settings = {
47
67
do : 'author' ,
48
- must_exclude : {
49
- regex : otherAuthorName
50
- }
68
+ none_of : [ authorName ]
69
+ }
70
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
71
+ expect ( filter . status ) . toBe ( 'fail' )
72
+ } )
73
+
74
+ test ( 'should pass with none_of author' , async ( ) => {
75
+ const author = new Author ( )
76
+ const settings = {
77
+ do : 'author' ,
78
+ none_of : [ otherAuthorName ]
51
79
}
52
80
const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
53
81
expect ( filter . status ) . toBe ( 'pass' )
@@ -67,6 +95,20 @@ test('should pass with expected author from correct team', async () => {
67
95
expect ( filter . status ) . toBe ( 'pass' )
68
96
} )
69
97
98
+ test ( 'should pass with one_of author from correct team' , async ( ) => {
99
+ const author = new Author ( )
100
+ const settings = {
101
+ do : 'author' ,
102
+ must_include : {
103
+ regex : authorName
104
+ } ,
105
+ one_of : [ '@org/team-slug' ]
106
+ }
107
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ authorName ] )
108
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
109
+ expect ( filter . status ) . toBe ( 'pass' )
110
+ } )
111
+
70
112
test ( 'should fail with expected author from incorrect team' , async ( ) => {
71
113
const author = new Author ( )
72
114
const settings = {
@@ -81,6 +123,20 @@ test('should fail with expected author from incorrect team', async () => {
81
123
expect ( filter . status ) . toBe ( 'fail' )
82
124
} )
83
125
126
+ test ( 'should fail with one_of author from incorrect team' , async ( ) => {
127
+ const author = new Author ( )
128
+ const settings = {
129
+ do : 'author' ,
130
+ must_include : {
131
+ regex : authorName
132
+ } ,
133
+ one_of : [ '@org/team-slug' ]
134
+ }
135
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ ] )
136
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
137
+ expect ( filter . status ) . toBe ( 'fail' )
138
+ } )
139
+
84
140
test ( 'should fail with unexpected author from correct team' , async ( ) => {
85
141
const author = new Author ( )
86
142
const settings = {
@@ -95,6 +151,20 @@ test('should fail with unexpected author from correct team', async () => {
95
151
expect ( filter . status ) . toBe ( 'fail' )
96
152
} )
97
153
154
+ test ( 'should fail with one_of author from correct team' , async ( ) => {
155
+ const author = new Author ( )
156
+ const settings = {
157
+ do : 'author' ,
158
+ must_include : {
159
+ regex : otherAuthorName
160
+ } ,
161
+ one_of : [ '@org/team-slug' ]
162
+ }
163
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ authorName ] )
164
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
165
+ expect ( filter . status ) . toBe ( 'fail' )
166
+ } )
167
+
98
168
test ( 'should pass when the author is a member of the team' , async ( ) => {
99
169
const author = new Author ( )
100
170
const settings = {
@@ -106,6 +176,17 @@ test('should pass when the author is a member of the team', async () => {
106
176
expect ( filter . status ) . toBe ( 'pass' )
107
177
} )
108
178
179
+ test ( 'should pass when the author is one_of the members of the team' , async ( ) => {
180
+ const author = new Author ( )
181
+ const settings = {
182
+ do : 'author' ,
183
+ one_of : [ '@org/team-slug' ]
184
+ }
185
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ authorName ] )
186
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
187
+ expect ( filter . status ) . toBe ( 'pass' )
188
+ } )
189
+
109
190
test ( 'should fail when the author is not a member of the team' , async ( ) => {
110
191
const author = new Author ( )
111
192
const authorName = 'mergeable'
@@ -118,6 +199,60 @@ test('should fail when the author is not a member of the team', async () => {
118
199
expect ( filter . status ) . toBe ( 'fail' )
119
200
} )
120
201
202
+ test ( 'should fail when the author is not one_of the members of the team' , async ( ) => {
203
+ const author = new Author ( )
204
+ const authorName = 'mergeable'
205
+ const settings = {
206
+ do : 'author' ,
207
+ one_of : [ '@org/team-slug' ]
208
+ }
209
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ otherAuthorName ] )
210
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
211
+ expect ( filter . status ) . toBe ( 'fail' )
212
+ } )
213
+
214
+ test ( 'should pass when the author is not member of the none_of team' , async ( ) => {
215
+ const author = new Author ( )
216
+ const settings = {
217
+ do : 'author' ,
218
+ none_of : [ '@org/team-slug' ]
219
+ }
220
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ otherAuthorName ] )
221
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
222
+ expect ( filter . status ) . toBe ( 'pass' )
223
+ } )
224
+
225
+ test ( 'should fail when the author is member of the none_of team' , async ( ) => {
226
+ const author = new Author ( )
227
+ const settings = {
228
+ do : 'author' ,
229
+ none_of : [ '@org/team-slug' ]
230
+ }
231
+ Teams . extractTeamMembers = jest . fn ( ) . mockReturnValue ( [ authorName ] )
232
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
233
+ expect ( filter . status ) . toBe ( 'fail' )
234
+ } )
235
+
236
+ test ( 'should pass when the author is one_of @author' , async ( ) => {
237
+ const author = new Author ( )
238
+ const settings = {
239
+ do : 'author' ,
240
+ one_of : [ '@author' ]
241
+ }
242
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
243
+ expect ( filter . status ) . toBe ( 'pass' )
244
+ } )
245
+
246
+ test ( 'should fail when the author is none_of @author' , async ( ) => {
247
+ const author = new Author ( )
248
+ const settings = {
249
+ do : 'author' ,
250
+ none_of : [ '@author' ]
251
+ }
252
+ const filter = await author . processFilter ( createMockContext ( authorName ) , settings )
253
+ expect ( filter . status ) . toBe ( 'fail' )
254
+ } )
255
+
121
256
const createMockContext = ( author ) => {
122
257
return Helper . mockContext ( { author } )
123
258
}
0 commit comments