Skip to content

Commit 25a4344

Browse files
committed
refactoring changes
1 parent 710da2f commit 25a4344

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

test/unit-tests/toolchain/swiftly.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
import { expect } from "chai";
1616
import { Swiftly } from "../../../src/toolchain/swiftly";
1717
import * as utilities from "../../../src/utilities/utilities";
18-
import { mockGlobalModule } from "../../MockUtils";
18+
import { mockGlobalModule, mockGlobalValue } from "../../MockUtils";
1919

2020
suite("Swiftly Unit Tests", () => {
2121
const mockUtilities = mockGlobalModule(utilities);
22+
const mockedPlatform = mockGlobalValue(process, "platform");
2223

2324
suite("getSwiftlyToolchainInstalls", () => {
2425
test("should return toolchain names from list-available command for version 1.1.0", async () => {
@@ -94,21 +95,12 @@ suite("Swiftly Unit Tests", () => {
9495
});
9596

9697
test("should return empty array when platform is not supported", async () => {
97-
const originalPlatform = process.platform;
98-
Object.defineProperty(process, "platform", {
99-
value: "win32",
100-
writable: true,
101-
});
98+
mockedPlatform.setValue("win32");
10299

103100
const result = await Swiftly.listAvailableToolchains();
104101

105102
expect(result).to.deep.equal([]);
106103
expect(mockUtilities.execFile).not.have.been.called;
107-
108-
Object.defineProperty(process, "platform", {
109-
value: originalPlatform,
110-
writable: true,
111-
});
112104
});
113105
});
114106
});

0 commit comments

Comments
 (0)