Skip to content

Commit 3b1bc51

Browse files
committed
refactor: moved unit test to separate file
1 parent 77b136e commit 3b1bc51

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ inputs:
66
required: true
77
releases-only:
88
description: If true, consider only tags that have an associated release
9+
default: "false"
910
prefix:
1011
description: Consider only tags starting with this string prefix
1112
regex:
1213
description: Consider only tags that matches specified RegEx pattern.
1314
sort-tags:
14-
description: If true, look through all tags to find the greatest (semver-like) version, else just get the most recent tag. Defaults to true (strongly recommended), or to false if *releases-only* is enabled
15+
description: |
16+
If true, look through all tags to find the greatest (semver-like) version, else just get the most recent tag.
17+
Defaults to true (strongly recommended), or to false if *releases-only* is enabled
18+
default: "true"
1519
token:
1620
description: Personal access token (auto-populated). It is used only because anonymous requests are rate-limited. It can be overridden to an empty value.
1721
default: ${{ github.token }}

getLatestTag.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const getLatestTag = require("./getLatestTag");
2+
3+
test("wait 500 ms", async () => {
4+
const start = new Date();
5+
await getLatestTag();
6+
const end = new Date();
7+
var delta = Math.abs(end - start);
8+
expect(delta).toBeGreaterThanOrEqual(500);
9+
});

index.test.js

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
const wait = require('./wait');
2-
const process = require('process');
3-
const cp = require('child_process');
4-
const path = require('path');
1+
const process = require("process");
2+
const cp = require("child_process");
3+
const path = require("path");
54

6-
test('throws invalid number', async () => {
7-
await expect(wait('foo')).rejects.toThrow('milliseconds not a number');
8-
});
9-
10-
test('wait 500 ms', async () => {
11-
const start = new Date();
12-
await wait(500);
13-
const end = new Date();
14-
var delta = Math.abs(end - start);
15-
expect(delta).toBeGreaterThanOrEqual(500);
16-
});
17-
18-
// shows how the runner will run a javascript action with env / stdout protocol
19-
test('test runs', () => {
20-
process.env['INPUT_MILLISECONDS'] = 100;
21-
const ip = path.join(__dirname, 'index.js');
22-
const result = cp.execSync(`node ${ip}`, {env: process.env}).toString();
5+
test("test runs", () => {
6+
process.env["INPUT_MILLISECONDS"] = 100;
7+
const ip = path.join(__dirname, "index.js");
8+
const result = cp.execSync(`node ${ip}`, { env: process.env }).toString();
239
console.log(result);
24-
})
10+
});

0 commit comments

Comments
 (0)