Skip to content

Commit

Permalink
Initial plugin version - Thanks ChatGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Feb 11, 2024
1 parent 412587d commit 2b88907
Show file tree
Hide file tree
Showing 6 changed files with 4,978 additions and 206 deletions.
46 changes: 4 additions & 42 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ let debugMock: jest.SpyInstance
let errorMock: jest.SpyInstance
let getInputMock: jest.SpyInstance
let setFailedMock: jest.SpyInstance

Check failure on line 22 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'setFailedMock' is assigned a value but never used

Check failure on line 22 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'setFailedMock' is assigned a value but never used
let setOutputMock: jest.SpyInstance

describe('action', () => {
beforeEach(() => {
Expand All @@ -30,60 +29,23 @@ describe('action', () => {
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'
case 'github_token':
return 'gh-token'
case 'regex_patterns':
return 'pattern1,pattern2'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
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()
})
})
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

Loading

0 comments on commit 2b88907

Please sign in to comment.