Fix paths in tests

This commit is contained in:
Sander Declerck 2025-07-23 11:43:13 +02:00
parent ccce2279c9
commit 5df4671988
No known key found for this signature in database
2 changed files with 34 additions and 12 deletions

View file

@ -75,7 +75,9 @@ describe("PowerShell Core shell integration", () => {
const content = fs.readFileSync(mockStartupFile, "utf-8"); const content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok( assert.ok(
content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script") content.includes(
'. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script'
)
); );
}); });
}); });
@ -84,7 +86,7 @@ describe("PowerShell Core shell integration", () => {
it("should remove init-pwsh.ps1 source line", () => { it("should remove init-pwsh.ps1 source line", () => {
const initialContent = [ const initialContent = [
"# PowerShell profile", "# PowerShell profile",
". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script", '. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script',
"Set-Alias ls Get-ChildItem", "Set-Alias ls Get-ChildItem",
"Set-Alias grep Select-String", "Set-Alias grep Select-String",
].join("\n"); ].join("\n");
@ -95,7 +97,9 @@ describe("PowerShell Core shell integration", () => {
assert.strictEqual(result, true); assert.strictEqual(result, true);
const content = fs.readFileSync(mockStartupFile, "utf-8"); const content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\"")); assert.ok(
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
);
assert.ok(content.includes("Set-Alias ls ")); assert.ok(content.includes("Set-Alias ls "));
assert.ok(content.includes("Set-Alias grep ")); assert.ok(content.includes("Set-Alias grep "));
}); });
@ -168,12 +172,16 @@ describe("PowerShell Core shell integration", () => {
// Setup // Setup
powershell.setup(); powershell.setup();
let content = fs.readFileSync(mockStartupFile, "utf-8"); let content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok(content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\"")); assert.ok(
content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
);
// Teardown // Teardown
powershell.teardown(knownAikidoTools); powershell.teardown(knownAikidoTools);
content = fs.readFileSync(mockStartupFile, "utf-8"); content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\"")); assert.ok(
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
);
}); });
it("should handle multiple setup calls", () => { it("should handle multiple setup calls", () => {
@ -182,7 +190,10 @@ describe("PowerShell Core shell integration", () => {
powershell.setup(); powershell.setup();
const content = fs.readFileSync(mockStartupFile, "utf-8"); const content = fs.readFileSync(mockStartupFile, "utf-8");
const sourceMatches = (content.match(/\. "\$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh\.ps1"/g) || []).length; const sourceMatches = (
content.match(/\. "\$HOME\\.safe-chain\\scripts\\init-pwsh\.ps1"/g) ||
[]
).length;
assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines"); assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines");
}); });
}); });

View file

@ -75,7 +75,9 @@ describe("Windows PowerShell shell integration", () => {
const content = fs.readFileSync(mockStartupFile, "utf-8"); const content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok( assert.ok(
content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script") content.includes(
'. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script'
)
); );
}); });
}); });
@ -84,7 +86,7 @@ describe("Windows PowerShell shell integration", () => {
it("should remove init-pwsh.ps1 source line", () => { it("should remove init-pwsh.ps1 source line", () => {
const initialContent = [ const initialContent = [
"# Windows PowerShell profile", "# Windows PowerShell profile",
". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\" # Safe-chain PowerShell initialization script", '. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1" # Safe-chain PowerShell initialization script',
"Set-Alias ls Get-ChildItem", "Set-Alias ls Get-ChildItem",
"Set-Alias grep Select-String", "Set-Alias grep Select-String",
].join("\n"); ].join("\n");
@ -95,7 +97,9 @@ describe("Windows PowerShell shell integration", () => {
assert.strictEqual(result, true); assert.strictEqual(result, true);
const content = fs.readFileSync(mockStartupFile, "utf-8"); const content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\"")); assert.ok(
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
);
assert.ok(content.includes("Set-Alias ls ")); assert.ok(content.includes("Set-Alias ls "));
assert.ok(content.includes("Set-Alias grep ")); assert.ok(content.includes("Set-Alias grep "));
}); });
@ -168,12 +172,16 @@ describe("Windows PowerShell shell integration", () => {
// Setup // Setup
windowsPowershell.setup(); windowsPowershell.setup();
let content = fs.readFileSync(mockStartupFile, "utf-8"); let content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok(content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\"")); assert.ok(
content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
);
// Teardown // Teardown
windowsPowershell.teardown(knownAikidoTools); windowsPowershell.teardown(knownAikidoTools);
content = fs.readFileSync(mockStartupFile, "utf-8"); content = fs.readFileSync(mockStartupFile, "utf-8");
assert.ok(!content.includes(". \"$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh.ps1\"")); assert.ok(
!content.includes('. "$HOME\\.safe-chain\\scripts\\init-pwsh.ps1"')
);
}); });
it("should handle multiple setup calls", () => { it("should handle multiple setup calls", () => {
@ -182,7 +190,10 @@ describe("Windows PowerShell shell integration", () => {
windowsPowershell.setup(); windowsPowershell.setup();
const content = fs.readFileSync(mockStartupFile, "utf-8"); const content = fs.readFileSync(mockStartupFile, "utf-8");
const sourceMatches = (content.match(/\. "\$HOME\\\\.safe-chain\\\\scripts\\\\init-pwsh\.ps1"/g) || []).length; const sourceMatches = (
content.match(/\. "\$HOME\\.safe-chain\\scripts\\init-pwsh\.ps1"/g) ||
[]
).length;
assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines"); assert.strictEqual(sourceMatches, 1, "Should not duplicate source lines");
}); });
}); });