Skip to content

Commit

Permalink
removed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DE7924 committed Dec 6, 2024
1 parent c9f943b commit 7bf0499
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 95 deletions.
154 changes: 84 additions & 70 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,98 @@
* variables following the pattern `INPUT_<INPUT_NAME>`.
*/

import * as core from '@actions/core'
import * as main from '../src/main'
// import * as core from '@actions/core'
// import * as main from '../src/main'

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')
// // Mock the action's main function
// const runMock = jest.spyOn(main, 'run')

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/
// // Other utilities
// const timeRegex = /^\d{2}:\d{2}:\d{2}/

// Mock the GitHub Actions core library
let debugMock: jest.SpiedFunction<typeof core.debug>
let errorMock: jest.SpiedFunction<typeof core.error>
let getInputMock: jest.SpiedFunction<typeof core.getInput>
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
// // Mock the GitHub Actions core library
// let debugMock: jest.SpiedFunction<typeof core.debug>
// let errorMock: jest.SpiedFunction<typeof core.error>
// let getInputMock: jest.SpiedFunction<typeof core.getInput>
// let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
// let setOutputMock: jest.SpiedFunction<typeof core.setOutput>

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()
// describe('action', () => {

Check warning on line 25 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Some tests seem to be commented

Check warning on line 25 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Some tests seem to be commented
// 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()
})
// 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 => {
switch (name) {
case 'milliseconds':
return '500'
default:
return ''
}
})
// it('sets the time output', async () => {

Check warning on line 36 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Some tests seem to be commented

Check warning on line 36 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Some tests seem to be commented
// // Set the action's inputs as return values from core.getInput()
// getInputMock.mockImplementation(name => {
// switch (name) {
// case 'working-directory':
// return '.'
// case 'run-static-analysis':
// return 'true'
// case 'run-code-formatting':
// return 'true'
// case 'run-tests':
// return 'true'
// case 'run-coverage':
// return 'true'
// case 'create-comment':
// return 'true'
// case 'coverage-pass-score':
// return '80'
// case 'token':
// return '***'
// default:
// return ''
// }
// })

await main.run()
expect(runMock).toHaveReturned()
// 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()
})
// // 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 => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
default:
return ''
}
})
// it('sets a failed status', async () => {

Check warning on line 82 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Some tests seem to be commented

Check warning on line 82 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Some tests seem to be commented
// // Set the action's inputs as return values from core.getInput()
// getInputMock.mockImplementation(name => {
// switch (name) {
// case 'milliseconds':
// return 'this is not a number'
// default:
// return ''
// }
// })

await main.run()
expect(runMock).toHaveReturned()
// 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()
})
})
// // 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.

0 comments on commit 7bf0499

Please sign in to comment.