Skip to content

Commit a119da9

Browse files
committed
Second
1 parent e60dfc4 commit a119da9

File tree

12 files changed

+1532
-126
lines changed

12 files changed

+1532
-126
lines changed

.github/linters/.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ rules:
7676
'@typescript-eslint/promise-function-async': 'error',
7777
'@typescript-eslint/require-array-sort-compare': 'error',
7878
'@typescript-eslint/restrict-plus-operands': 'error',
79-
'@typescript-eslint/semi': ['error', 'never'],
79+
'@typescript-eslint/semi': 'off',
8080
'@typescript-eslint/space-before-function-paren': 'off',
8181
'@typescript-eslint/type-annotation-spacing': 'error',
8282
'@typescript-eslint/unbound-method': 'error'

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"printWidth": 80,
33
"tabWidth": 2,
44
"useTabs": false,
5-
"semi": false,
5+
"semi": true,
66
"singleQuote": true,
77
"quoteProps": "as-needed",
88
"jsxSingleQuote": false,

__tests__/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
* Unit tests for the action's entrypoint, src/index.ts
33
*/
44

5-
import * as main from '../src/main'
5+
import * as main from '../src/main';
66

77
// Mock the action's entrypoint
8-
const runMock = jest.spyOn(main, 'run').mockImplementation()
8+
const runMock = jest.spyOn(main, 'run').mockImplementation();
99

1010
describe('index', () => {
1111
it('calls run when imported', async () => {
1212
// eslint-disable-next-line @typescript-eslint/no-require-imports
13-
require('../src/index')
13+
require('../src/index');
1414

15-
expect(runMock).toHaveBeenCalled()
16-
})
17-
})
15+
expect(runMock).toHaveBeenCalled();
16+
});
17+
});

__tests__/main.test.ts

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,87 @@
66
* variables following the pattern `INPUT_<INPUT_NAME>`.
77
*/
88

9-
import * as core from '@actions/core'
10-
import * as main from '../src/main'
9+
import * as core from '@actions/core';
10+
import * as main from '../src/main';
1111

1212
// Mock the action's main function
13-
const runMock = jest.spyOn(main, 'run')
13+
const runMock = jest.spyOn(main, 'run');
1414

1515
// Other utilities
16-
const timeRegex = /^\d{2}:\d{2}:\d{2}/
16+
const timeRegex = /^\d{2}:\d{2}:\d{2}/;
1717

1818
// Mock the GitHub Actions core library
19-
let debugMock: jest.SpiedFunction<typeof core.debug>
20-
let errorMock: jest.SpiedFunction<typeof core.error>
21-
let getInputMock: jest.SpiedFunction<typeof core.getInput>
22-
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
23-
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
19+
let debugMock: jest.SpiedFunction<typeof core.debug>;
20+
let errorMock: jest.SpiedFunction<typeof core.error>;
21+
let getInputMock: jest.SpiedFunction<typeof core.getInput>;
22+
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
23+
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>;
2424

2525
describe('action', () => {
2626
beforeEach(() => {
27-
jest.clearAllMocks()
27+
jest.clearAllMocks();
2828

29-
debugMock = jest.spyOn(core, 'debug').mockImplementation()
30-
errorMock = jest.spyOn(core, 'error').mockImplementation()
31-
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
32-
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
33-
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
34-
})
29+
debugMock = jest.spyOn(core, 'debug').mockImplementation();
30+
errorMock = jest.spyOn(core, 'error').mockImplementation();
31+
getInputMock = jest.spyOn(core, 'getInput').mockImplementation();
32+
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation();
33+
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation();
34+
});
3535

3636
it('sets the time output', async () => {
3737
// Set the action's inputs as return values from core.getInput()
3838
getInputMock.mockImplementation(name => {
3939
switch (name) {
4040
case 'milliseconds':
41-
return '500'
41+
return '500';
4242
default:
43-
return ''
43+
return '';
4444
}
45-
})
45+
});
4646

47-
await main.run()
48-
expect(runMock).toHaveReturned()
47+
await main.run();
48+
expect(runMock).toHaveReturned();
4949

5050
// Verify that all of the core library functions were called correctly
51-
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
51+
expect(debugMock).toHaveBeenNthCalledWith(
52+
1,
53+
'Waiting 500 milliseconds ...'
54+
);
5255
expect(debugMock).toHaveBeenNthCalledWith(
5356
2,
5457
expect.stringMatching(timeRegex)
55-
)
58+
);
5659
expect(debugMock).toHaveBeenNthCalledWith(
5760
3,
5861
expect.stringMatching(timeRegex)
59-
)
62+
);
6063
expect(setOutputMock).toHaveBeenNthCalledWith(
6164
1,
6265
'time',
6366
expect.stringMatching(timeRegex)
64-
)
65-
expect(errorMock).not.toHaveBeenCalled()
66-
})
67+
);
68+
expect(errorMock).not.toHaveBeenCalled();
69+
});
6770

6871
it('sets a failed status', async () => {
6972
// Set the action's inputs as return values from core.getInput()
7073
getInputMock.mockImplementation(name => {
7174
switch (name) {
7275
case 'milliseconds':
73-
return 'this is not a number'
76+
return 'this is not a number';
7477
default:
75-
return ''
78+
return '';
7679
}
77-
})
80+
});
7881

79-
await main.run()
80-
expect(runMock).toHaveReturned()
82+
await main.run();
83+
expect(runMock).toHaveReturned();
8184

8285
// Verify that all of the core library functions were called correctly
8386
expect(setFailedMock).toHaveBeenNthCalledWith(
8487
1,
8588
'milliseconds not a number'
86-
)
87-
expect(errorMock).not.toHaveBeenCalled()
88-
})
89-
})
89+
);
90+
expect(errorMock).not.toHaveBeenCalled();
91+
});
92+
});

__tests__/wait.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
* Unit tests for src/wait.ts
33
*/
44

5-
import { wait } from '../src/wait'
6-
import { expect } from '@jest/globals'
5+
import { wait } from '../src/wait';
6+
import { expect } from '@jest/globals';
77

88
describe('wait.ts', () => {
99
it('throws an invalid number', async () => {
10-
const input = parseInt('foo', 10)
11-
expect(isNaN(input)).toBe(true)
10+
const input = parseInt('foo', 10);
11+
expect(isNaN(input)).toBe(true);
1212

13-
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
14-
})
13+
await expect(wait(input)).rejects.toThrow('milliseconds not a number');
14+
});
1515

1616
it('waits with a valid number', async () => {
17-
const start = new Date()
18-
await wait(500)
19-
const end = new Date()
17+
const start = new Date();
18+
await wait(500);
19+
const end = new Date();
2020

21-
const delta = Math.abs(end.getTime() - start.getTime())
21+
const delta = Math.abs(end.getTime() - start.getTime());
2222

23-
expect(delta).toBeGreaterThan(450)
24-
})
25-
})
23+
expect(delta).toBeGreaterThan(450);
24+
});
25+
});

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)