Skip to content

Commit

Permalink
style(linter): resolve failing linters
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Field <jason@avon-lea.co.uk>
  • Loading branch information
xorima committed Oct 17, 2023
1 parent b4ca457 commit 13e6783
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 50 deletions.
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,17 @@ import * as core from '@actions/core'
import * as main from '../src/main'

// Mock the GitHub Actions core library
const debugMock = jest.spyOn(core, 'debug')
const getInputMock = jest.spyOn(core, 'getInput')
const setFailedMock = jest.spyOn(core, 'setFailed')
const setOutputMock = jest.spyOn(core, 'setOutput')

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

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

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

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(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)
)
})

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { App } from '@octokit/app'

async function getInstallationId(app: App, owner: string): Promise<number> {
for await (const { installation } of app.eachInstallation.iterator()) {
if (installation.account?.login.toLowerCase() == owner.toLowerCase()) {
if (installation.account?.login.toLowerCase() === owner.toLowerCase()) {
return installation.id
}
}
Expand Down Expand Up @@ -37,10 +37,10 @@ function newGitHubApp(
clientSecret: string
): App {
return new App({
appId: appId,
privateKey: privateKey,
clientId: clientId,
clientSecret: clientSecret
appId,
privateKey,
clientId,
clientSecret
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export async function run(): Promise<void> {

core.info('searching for installation')
const app = newGitHubApp(appId, privateKey, clientId, clientSecret)
var id = await getInstallationId(app, owner)
const id = await getInstallationId(app, owner)
core.info('found installation id, getting token')
var token = await getInstallationToken(
const token = await getInstallationToken(
appId,
privateKey,
clientId,
Expand Down

0 comments on commit 13e6783

Please sign in to comment.