generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
98 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// /** | ||
// * Unit tests for the action's main functionality, src/main.ts | ||
// * | ||
// * These should be run as if the action was called from a workflow. | ||
// * Specifically, the inputs listed in `action.yml` should be set as environment | ||
// * variables following the pattern `INPUT_<INPUT_NAME>`. | ||
// */ | ||
|
||
// import * as core from '@actions/core' | ||
// import * as main from '../src/main' | ||
|
||
// // Mock the action's main function | ||
// const runMock = jest.spyOn(main, 'run') | ||
|
||
// // Other utilities | ||
// const timeRegex = /^\d{2}:\d{2}:\d{2}/ | ||
|
||
// // Mock the GitHub Actions core library | ||
// let debugMock: jest.SpyInstance | ||
// let errorMock: jest.SpyInstance | ||
// let getInputMock: jest.SpyInstance | ||
// let setFailedMock: jest.SpyInstance | ||
// let setOutputMock: jest.SpyInstance | ||
|
||
// describe('action', () => { | ||
// beforeEach(() => { | ||
// jest.clearAllMocks() | ||
|
||
// debugMock = jest.spyOn(core, 'debug').mockImplementation() | ||
// errorMock = jest.spyOn(core, 'error').mockImplementation() | ||
// getInputMock = jest.spyOn(core, 'getInput').mockImplementation() | ||
// setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation() | ||
// setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation() | ||
// }) | ||
|
||
// it('sets the time output', async () => { | ||
// // Set the action's inputs as return values from core.getInput() | ||
// getInputMock.mockImplementation((name: string): string => { | ||
// switch (name) { | ||
// case 'milliseconds': | ||
// return '500' | ||
// default: | ||
// return '' | ||
// } | ||
// }) | ||
|
||
// await main.run() | ||
// expect(runMock).toHaveReturned() | ||
|
||
// // Verify that all of the core library functions were called correctly | ||
// expect(debugMock).toHaveBeenNthCalledWith( | ||
// 2, | ||
// expect.stringMatching(timeRegex) | ||
// ) | ||
// expect(debugMock).toHaveBeenNthCalledWith( | ||
// 3, | ||
// expect.stringMatching(timeRegex) | ||
// ) | ||
// expect(setOutputMock).toHaveBeenNthCalledWith( | ||
// 1, | ||
// 'time', | ||
// expect.stringMatching(timeRegex) | ||
// ) | ||
// expect(errorMock).not.toHaveBeenCalled() | ||
// }) | ||
|
||
// it('sets a failed status', async () => { | ||
// // Set the action's inputs as return values from core.getInput() | ||
// getInputMock.mockImplementation((name: string): string => { | ||
// switch (name) { | ||
// case 'milliseconds': | ||
// return 'this is not a number' | ||
// default: | ||
// return '' | ||
// } | ||
// }) | ||
|
||
// await main.run() | ||
// expect(runMock).toHaveReturned() | ||
|
||
// // Verify that all of the core library functions were called correctly | ||
// expect(setFailedMock).toHaveBeenNthCalledWith( | ||
// 1, | ||
// 'milliseconds not a number' | ||
// ) | ||
// expect(errorMock).not.toHaveBeenCalled() | ||
// }) | ||
// }) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters