|
15 | 15 | import { expect } from "chai";
|
16 | 16 | import { Swiftly } from "../../../src/toolchain/swiftly";
|
17 | 17 | import * as utilities from "../../../src/utilities/utilities";
|
18 |
| -import { mockGlobalModule } from "../../MockUtils"; |
| 18 | +import { mockGlobalModule, mockGlobalValue } from "../../MockUtils"; |
19 | 19 |
|
20 | 20 | suite("Swiftly Unit Tests", () => {
|
21 | 21 | const mockUtilities = mockGlobalModule(utilities);
|
| 22 | + const mockedPlatform = mockGlobalValue(process, "platform"); |
22 | 23 |
|
23 | 24 | suite("getSwiftlyToolchainInstalls", () => {
|
24 | 25 | test("should return toolchain names from list-available command for version 1.1.0", async () => {
|
@@ -94,21 +95,12 @@ suite("Swiftly Unit Tests", () => {
|
94 | 95 | });
|
95 | 96 |
|
96 | 97 | 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"); |
102 | 99 |
|
103 | 100 | const result = await Swiftly.listAvailableToolchains();
|
104 | 101 |
|
105 | 102 | expect(result).to.deep.equal([]);
|
106 | 103 | expect(mockUtilities.execFile).not.have.been.called;
|
107 |
| - |
108 |
| - Object.defineProperty(process, "platform", { |
109 |
| - value: originalPlatform, |
110 |
| - writable: true, |
111 |
| - }); |
112 | 104 | });
|
113 | 105 | });
|
114 | 106 | });
|
0 commit comments