@@ -5,7 +5,7 @@ const core = require('@actions/core');
55const main = require ( '../src/main' ) ;
66
77// Mock the GitHub Actions core library
8- const debugMock = jest . spyOn ( core , 'debug' ) . mockImplementation ( ) ;
8+ // const debugMock = jest.spyOn(core, 'debug').mockImplementation();
99const getInputMock = jest . spyOn ( core , 'getInput' ) . mockImplementation ( ) ;
1010const setFailedMock = jest . spyOn ( core , 'setFailed' ) . mockImplementation ( ) ;
1111const setOutputMock = jest . spyOn ( core , 'setOutput' ) . mockImplementation ( ) ;
@@ -25,64 +25,41 @@ describe('action', () => {
2525 // Set the action's inputs as return values from core.getInput()
2626 getInputMock . mockImplementation ( name => {
2727 switch ( name ) {
28- case 'milliseconds ' :
29- return '500 ' ;
28+ case 'sapi ' :
29+ return 'cli,fpm ' ;
3030 default :
3131 return '' ;
3232 }
3333 } ) ;
3434
3535 await main . run ( ) ;
3636 expect ( runMock ) . toHaveReturned ( ) ;
37-
38- // Verify that all of the core library functions were called correctly
39- expect ( debugMock ) . toHaveBeenNthCalledWith (
40- 1 ,
41- 'Waiting 500 milliseconds ...'
42- ) ;
43- expect ( debugMock ) . toHaveBeenNthCalledWith (
44- 2 ,
45- expect . stringMatching ( timeRegex )
46- ) ;
47- expect ( debugMock ) . toHaveBeenNthCalledWith (
48- 3 ,
49- expect . stringMatching ( timeRegex )
50- ) ;
51- expect ( setOutputMock ) . toHaveBeenNthCalledWith (
52- 1 ,
53- 'time' ,
54- expect . stringMatching ( timeRegex )
55- ) ;
37+ expect ( setOutputMock ) . toHaveBeenNthCalledWith ( 1 , 'sapi' , 'cli,fpm' ) ;
5638 } ) ;
5739
58- it ( 'sets a failed status ' , async ( ) => {
40+ it ( 'sets the wrong sapi name ' , async ( ) => {
5941 // Set the action's inputs as return values from core.getInput()
6042 getInputMock . mockImplementation ( name => {
6143 switch ( name ) {
62- case 'milliseconds ' :
63- return 'this is not a number ' ;
44+ case 'sapi ' :
45+ return 'foo ' ;
6446 default :
6547 return '' ;
6648 }
6749 } ) ;
6850
6951 await main . run ( ) ;
7052 expect ( runMock ) . toHaveReturned ( ) ;
71-
72- // Verify that all of the core library functions were called correctly
73- expect ( setFailedMock ) . toHaveBeenNthCalledWith (
74- 1 ,
75- 'milliseconds not a number'
76- ) ;
53+ expect ( setFailedMock ) . toHaveBeenNthCalledWith ( 1 , 'Invalid sapi' ) ;
7754 } ) ;
7855
7956 it ( 'fails if no input is provided' , async ( ) => {
8057 // Set the action's inputs as return values from core.getInput()
8158 getInputMock . mockImplementation ( name => {
8259 switch ( name ) {
83- case 'milliseconds ' :
60+ case 'sapi ' :
8461 throw new Error (
85- 'Input required and not supplied: milliseconds '
62+ 'Need to input a valid sapi: cli, fpm, micro, embed '
8663 ) ;
8764 default :
8865 return '' ;
@@ -95,7 +72,7 @@ describe('action', () => {
9572 // Verify that all of the core library functions were called correctly
9673 expect ( setFailedMock ) . toHaveBeenNthCalledWith (
9774 1 ,
98- 'Input required and not supplied: milliseconds '
75+ 'Need to input a valid sapi: cli, fpm, micro, embed '
9976 ) ;
10077 } ) ;
10178} ) ;
0 commit comments