Skip to content

Commit 57042b1

Browse files
committed
Make environmentVars non-optional in platform.tests.ts
1 parent 7e80fe5 commit 57042b1

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

test/core/platform.test.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface ITestPlatform {
4444
name: string;
4545
platformDetails: platform.IPlatformDetails;
4646
filesystem: FileSystem.DirectoryItems;
47-
environmentVars?: Record<string, string>;
47+
environmentVars: Record<string, string>;
4848
}
4949

5050
/**
@@ -442,6 +442,7 @@ if (process.platform === "win32") {
442442
isOS64Bit: true,
443443
isProcess64Bit: true,
444444
},
445+
environmentVars: {},
445446
expectedPowerShellSequence: [
446447
{
447448
exePath: "/usr/bin/pwsh",
@@ -482,6 +483,7 @@ if (process.platform === "win32") {
482483
isOS64Bit: true,
483484
isProcess64Bit: true,
484485
},
486+
environmentVars: {},
485487
expectedPowerShellSequence: [
486488
{
487489
exePath: "/usr/local/bin/pwsh",
@@ -508,6 +510,7 @@ if (process.platform === "win32") {
508510
isOS64Bit: true,
509511
isProcess64Bit: true,
510512
},
513+
environmentVars: {},
511514
expectedPowerShellSequence: [
512515
{
513516
exePath: "/usr/bin/pwsh",
@@ -528,6 +531,7 @@ if (process.platform === "win32") {
528531
isOS64Bit: true,
529532
isProcess64Bit: true,
530533
},
534+
environmentVars: {},
531535
expectedPowerShellSequence: [
532536
{
533537
exePath: "/snap/bin/pwsh",
@@ -548,6 +552,7 @@ if (process.platform === "win32") {
548552
isOS64Bit: true,
549553
isProcess64Bit: true,
550554
},
555+
environmentVars: {},
551556
expectedPowerShellSequence: [
552557
{
553558
exePath: "/usr/local/bin/pwsh",
@@ -620,6 +625,7 @@ const errorTestCases: ITestPlatform[] = [
620625
isOS64Bit: true,
621626
isProcess64Bit: true,
622627
},
628+
environmentVars: {},
623629
filesystem: {},
624630
},
625631
{
@@ -629,17 +635,16 @@ const errorTestCases: ITestPlatform[] = [
629635
isOS64Bit: true,
630636
isProcess64Bit: true,
631637
},
638+
environmentVars: {},
632639
filesystem: {},
633640
},
634641
];
635642

636643
function setupTestEnvironment(testPlatform: ITestPlatform) {
637644
mockFS(testPlatform.filesystem);
638645

639-
if (testPlatform.environmentVars) {
640-
for (const envVar of Object.keys(testPlatform.environmentVars)) {
641-
sinon.stub(process.env, envVar).value(testPlatform.environmentVars[envVar]);
642-
}
646+
for (const envVar of Object.keys(testPlatform.environmentVars)) {
647+
sinon.stub(process.env, envVar).value(testPlatform.environmentVars[envVar]);
643648
}
644649
}
645650

@@ -712,9 +717,9 @@ describe("Platform module", function () {
712717
const defaultPowerShell = await powerShellExeFinder.getFirstAvailablePowerShellInstallation();
713718
const expectedPowerShell = testPlatform.expectedPowerShellSequence[0];
714719

715-
assert.strictEqual(defaultPowerShell.exePath, expectedPowerShell.exePath);
716-
assert.strictEqual(defaultPowerShell.displayName, expectedPowerShell.displayName);
717-
assert.strictEqual(defaultPowerShell.supportsProperArguments, expectedPowerShell.supportsProperArguments);
720+
assert.strictEqual(defaultPowerShell.exePath, expectedPowerShell!.exePath);
721+
assert.strictEqual(defaultPowerShell.displayName, expectedPowerShell!.displayName);
722+
assert.strictEqual(defaultPowerShell.supportsProperArguments, expectedPowerShell!.supportsProperArguments);
718723
});
719724
}
720725

@@ -748,9 +753,9 @@ describe("Platform module", function () {
748753
const foundPowerShell = foundPowerShells[i];
749754
const expectedPowerShell = testPlatform.expectedPowerShellSequence[i];
750755

751-
assert.strictEqual(foundPowerShell && foundPowerShell.exePath, expectedPowerShell.exePath);
752-
assert.strictEqual(foundPowerShell && foundPowerShell.displayName, expectedPowerShell.displayName);
753-
assert.strictEqual(foundPowerShell && foundPowerShell.supportsProperArguments, expectedPowerShell.supportsProperArguments);
756+
assert.strictEqual(foundPowerShell && foundPowerShell.exePath, expectedPowerShell!.exePath);
757+
assert.strictEqual(foundPowerShell && foundPowerShell.displayName, expectedPowerShell!.displayName);
758+
assert.strictEqual(foundPowerShell && foundPowerShell.supportsProperArguments, expectedPowerShell!.supportsProperArguments);
754759
}
755760

756761
assert.strictEqual(
@@ -786,7 +791,7 @@ describe("Platform module", function () {
786791

787792
function getWinPSPath(systemDir: string) {
788793
return path.join(
789-
testPlatform.environmentVars!.windir,
794+
testPlatform.environmentVars.windir!,
790795
systemDir,
791796
"WindowsPowerShell",
792797
"v1.0",

0 commit comments

Comments
 (0)