Skip to content

Commit 4d82e5a

Browse files
committed
spy/mock from the actual implementations
1 parent d967e31 commit 4d82e5a

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

__tests__/codeartifact.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import * as codeartifact from '@aws-sdk/client-codeartifact'
66
import { getToken } from '../src/codeartifact'
77

8-
let sendMock: jest.SpyInstance
8+
let sendMock: jest.SpiedFunction<
9+
typeof codeartifact.CodeartifactClient.prototype.send
10+
>
911
describe('codeartifact', () => {
1012
beforeEach(() => {
1113
jest.clearAllMocks()

__tests__/main.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import * as main from '../src/main'
66
import * as codeartifact from '../src/codeartifact'
77

88
// Mock the GitHub Actions core library
9-
let infoMock: jest.SpyInstance
10-
let getInputMock: jest.SpyInstance
11-
let setFailedMock: jest.SpyInstance
12-
let setOutputMock: jest.SpyInstance
13-
let getTokenMock: jest.SpyInstance
9+
let infoMock: jest.SpiedFunction<typeof core.info>
10+
let getInputMock: jest.SpiedFunction<typeof core.getInput>
11+
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
12+
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
13+
let getTokenMock: jest.SpiedFunction<typeof codeartifact.getToken>
1414

1515
// Mock the action's main function
1616
const runMock = jest.spyOn(main, 'run')
@@ -31,7 +31,7 @@ describe('action', () => {
3131

3232
it('sets the token output', async () => {
3333
// Set the action's inputs as return values from core.getInput()
34-
getInputMock.mockImplementation((name: string) => {
34+
getInputMock.mockImplementation(name => {
3535
switch (name) {
3636
case 'domain':
3737
return 'interopio'
@@ -70,7 +70,7 @@ describe('action', () => {
7070

7171
it('sets a failed status', async () => {
7272
// Set the action's inputs as return values from core.getInput()
73-
getInputMock.mockImplementation((name: string) => {
73+
getInputMock.mockImplementation(name => {
7474
switch (name) {
7575
case 'region':
7676
return 'eu-central-1'
@@ -95,7 +95,7 @@ describe('action', () => {
9595

9696
it('fails if no input is provided', async () => {
9797
// Set the action's inputs as return values from core.getInput()
98-
getInputMock.mockImplementation((name: string) => {
98+
getInputMock.mockImplementation(name => {
9999
switch (name) {
100100
case 'domain':
101101
case 'domain-owner':

0 commit comments

Comments
 (0)