@@ -314,6 +314,33 @@ describe("Auto", () => {
314314 expect ( console . log ) . toHaveBeenCalledWith ( "foo" ) ;
315315 } ) ;
316316
317+ test ( "should check for a given label" , async ( ) => {
318+ const auto = new Auto ( defaults ) ;
319+ auto . logger = dummyLog ( ) ;
320+ await auto . loadConfig ( ) ;
321+
322+ const getLabels = jest . fn ( ) ;
323+ auto . git ! . getLabels = getLabels ;
324+ getLabels . mockReturnValueOnce ( [ "foo" ] ) ;
325+ jest . spyOn ( console , "log" ) . mockImplementation ( ) ;
326+
327+ await auto . label ( { pr : 13 , exists : "foo" } ) ;
328+ expect ( console . log ) . toHaveBeenCalledWith ( "foo" ) ;
329+ } ) ;
330+
331+ test ( "should throw if a check for a label fails" , async ( ) => {
332+ const auto = new Auto ( defaults ) ;
333+ auto . logger = dummyLog ( ) ;
334+ await auto . loadConfig ( ) ;
335+
336+ const getLabels = jest . fn ( ) ;
337+ auto . git ! . getLabels = getLabels ;
338+ getLabels . mockReturnValueOnce ( [ "bar" ] ) ;
339+ jest . spyOn ( console , "log" ) . mockImplementation ( ) ;
340+
341+ await expect ( auto . label ( { pr : 13 , exists : "foo" } ) ) . rejects . toThrow ( ) ;
342+ } ) ;
343+
317344 test ( "should get labels for last merged PR" , async ( ) => {
318345 const auto = new Auto ( defaults ) ;
319346 auto . logger = dummyLog ( ) ;
0 commit comments