Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncalteen committed Nov 1, 2023
1 parent 4a91017 commit 3a4c22f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
8 changes: 7 additions & 1 deletion __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import * as main from '../src/main'

// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()
let runMock: jest.SpyInstance

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

runMock = jest.spyOn(main, 'run').mockImplementation()
})

it('calls run when imported', async () => {
require('../src/index')

Expand Down
14 changes: 10 additions & 4 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import * as core from '@actions/core'
import * as main from '../src/main'

// Mock the GitHub Actions core library
const getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
let getInputMock: jest.SpyInstance
let setFailedMock: jest.SpyInstance
let setOutputMock: jest.SpyInstance

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

// Mock Octokit
jest.mock('@octokit/rest', () => ({
Expand All @@ -21,6 +21,12 @@ jest.mock('@octokit/rest', () => ({
describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()

runMock = jest.spyOn(main, 'run')
})

it('reads valid inputs', async () => {
Expand Down

0 comments on commit 3a4c22f

Please sign in to comment.