Skip to content

Commit 32dccc8

Browse files
fix: more tests, more stability
1 parent 887f717 commit 32dccc8

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/tests/input.test.ts

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
11
import { get } from "../input";
22

33
describe("input", () => {
4-
test("get", () => {
4+
const OLD_ENV = process.env;
5+
6+
beforeEach(() => {
7+
process.env = { ...OLD_ENV };
8+
});
9+
10+
afterAll(() => {
11+
process.env = OLD_ENV;
12+
});
13+
14+
test("get 1, parses defaults", () => {
515
expect(get()).toStrictEqual({ args: [], toolchain: undefined, useCross: false });
616
});
17+
18+
test("get 2, can use cross", () => {
19+
process.env["INPUT_USE-CROSS"] = "true";
20+
expect(get()).toStrictEqual({ args: [], toolchain: undefined, useCross: true });
21+
});
22+
23+
test("get 3, parses toolchain", () => {
24+
process.env["INPUT_TOOLCHAIN"] = "nightly";
25+
expect(get()).toStrictEqual({ args: [], toolchain: "nightly", useCross: false });
26+
});
27+
28+
test("get 4, parses +toolchain to toolchain", () => {
29+
process.env["INPUT_TOOLCHAIN"] = "+nightly";
30+
expect(get()).toStrictEqual({ args: [], toolchain: "nightly", useCross: false });
31+
});
32+
33+
test("get 5, parses arguments", () => {
34+
process.env["INPUT_ARGS"] = "--all-features --all-targets";
35+
expect(get()).toStrictEqual({ args: ["--all-features", "--all-targets"], toolchain: undefined, useCross: false });
36+
});
737
});

0 commit comments

Comments
 (0)