@@ -35,6 +35,7 @@ describe("Required Labels", () => {
35
35
} ;
36
36
tools . exit . success = jest . fn ( ) ;
37
37
tools . exit . failure = jest . fn ( ) ;
38
+ tools . exit . neutral = jest . fn ( ) ;
38
39
} ) ;
39
40
40
41
afterEach ( ( ) => {
@@ -170,6 +171,21 @@ describe("Required Labels", () => {
170
171
"Unknown mode input [bananas]. Must be one of: exactly, minimum, maximum"
171
172
) ;
172
173
} ) ;
174
+
175
+ it ( "unknown exit_code" , ( ) => {
176
+ restoreTest = mockPr ( tools , [ ] , {
177
+ INPUT_MODE : "exactly" ,
178
+ INPUT_LABELS : "enhancement,bug" ,
179
+ INPUT_COUNT : "1" ,
180
+ INPUT_EXIT_TYPE : "other" ,
181
+ } ) ;
182
+
183
+ action ( tools ) ;
184
+ expect ( tools . exit . failure ) . toBeCalledTimes ( 1 ) ;
185
+ expect ( tools . exit . failure ) . toBeCalledWith (
186
+ "Unknown exit_code input [other]. Must be one of: success, neutral, failure"
187
+ ) ;
188
+ } ) ;
173
189
} ) ;
174
190
175
191
describe ( "data integrity" , ( ) => {
@@ -210,6 +226,68 @@ describe("Required Labels", () => {
210
226
expect ( tools . exit . success ) . toBeCalledWith ( "Complete" ) ;
211
227
} ) ;
212
228
} ) ;
229
+
230
+ describe ( "configurable exit code" , ( ) => {
231
+ it ( "defaults to failure" , ( ) => {
232
+ // Create a new Toolkit instance
233
+ restoreTest = mockPr ( tools , [ "enhancement" , "bug" ] , {
234
+ INPUT_LABELS : "enhancement,bug" ,
235
+ INPUT_MODE : "exactly" ,
236
+ INPUT_COUNT : "1" ,
237
+ } ) ;
238
+
239
+ action ( tools ) ;
240
+ expect ( tools . exit . failure ) . toBeCalledTimes ( 1 ) ;
241
+ expect ( tools . exit . failure ) . toBeCalledWith (
242
+ "Label error. Requires exactly 1 of: enhancement, bug. Found: enhancement, bug"
243
+ ) ;
244
+ } ) ;
245
+
246
+ it ( "explicitly uses failure" , ( ) => {
247
+ restoreTest = mockPr ( tools , [ "enhancement" , "bug" ] , {
248
+ INPUT_LABELS : "enhancement,bug" ,
249
+ INPUT_MODE : "exactly" ,
250
+ INPUT_COUNT : "1" ,
251
+ INPUT_EXIT_TYPE : "failure" ,
252
+ } ) ;
253
+
254
+ action ( tools ) ;
255
+ expect ( tools . exit . failure ) . toBeCalledTimes ( 1 ) ;
256
+ expect ( tools . exit . failure ) . toBeCalledWith (
257
+ "Label error. Requires exactly 1 of: enhancement, bug. Found: enhancement, bug"
258
+ ) ;
259
+ } ) ;
260
+
261
+ it ( "explicitly uses success" , ( ) => {
262
+ restoreTest = mockPr ( tools , [ "enhancement" , "bug" ] , {
263
+ INPUT_LABELS : "enhancement,bug" ,
264
+ INPUT_MODE : "exactly" ,
265
+ INPUT_COUNT : "1" ,
266
+ INPUT_EXIT_TYPE : "success" ,
267
+ } ) ;
268
+
269
+ action ( tools ) ;
270
+ expect ( tools . exit . success ) . toBeCalledTimes ( 1 ) ;
271
+ expect ( tools . exit . success ) . toBeCalledWith (
272
+ "Label error. Requires exactly 1 of: enhancement, bug. Found: enhancement, bug"
273
+ ) ;
274
+ } ) ;
275
+
276
+ it ( "explicitly uses neutral" , ( ) => {
277
+ restoreTest = mockPr ( tools , [ "enhancement" , "bug" ] , {
278
+ INPUT_LABELS : "enhancement,bug" ,
279
+ INPUT_MODE : "exactly" ,
280
+ INPUT_COUNT : "1" ,
281
+ INPUT_EXIT_TYPE : "neutral" ,
282
+ } ) ;
283
+
284
+ action ( tools ) ;
285
+ expect ( tools . exit . neutral ) . toBeCalledTimes ( 1 ) ;
286
+ expect ( tools . exit . neutral ) . toBeCalledWith (
287
+ "Label error. Requires exactly 1 of: enhancement, bug. Found: enhancement, bug"
288
+ ) ;
289
+ } ) ;
290
+ } ) ;
213
291
} ) ;
214
292
215
293
function mockPr ( tools , labels , env ) {
0 commit comments