-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/unit/private/ConvertTo-WikiSidebarLinkName.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#region HEADER | ||
$script:projectPath = "$PSScriptRoot\..\..\.." | Convert-Path | ||
$script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { | ||
($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and | ||
$(try | ||
{ | ||
Test-ModuleManifest -Path $_.FullName -ErrorAction Stop | ||
} | ||
catch | ||
{ | ||
$false | ||
}) | ||
}).BaseName | ||
|
||
$script:moduleName = Get-Module -Name $script:projectName -ListAvailable | Select-Object -First 1 | ||
Remove-Module -Name $script:moduleName -Force -ErrorAction 'SilentlyContinue' | ||
|
||
Import-Module $script:moduleName -Force -ErrorAction 'Stop' | ||
#endregion HEADER | ||
|
||
InModuleScope $script:moduleName { | ||
Describe 'ConvertTo-WikiSidebarLinkName' { | ||
Context 'When converting a simple hyphenated name' { | ||
It 'Should replace hyphens with spaces' { | ||
$result = ConvertTo-WikiSidebarLinkName -Name 'My-Page-Name' | ||
$result | Should -Be 'My Page Name' | ||
} | ||
} | ||
|
||
Context 'When converting a name with Unicode hyphens' { | ||
It 'Should replace Unicode hyphens with standard hyphens' { | ||
$result = ConvertTo-WikiSidebarLinkName -Name 'Unicode‑Hyphen' # Note: The hyphen here is a Unicode hyphen (U+2010) | ||
$result | Should -Be 'Unicode-Hyphen' | ||
} | ||
} | ||
|
||
Context 'When the input is piped' { | ||
It 'Should process the piped input correctly' { | ||
'Piped-Input' | ConvertTo-WikiSidebarLinkName | Should -Be 'Piped Input' | ||
} | ||
} | ||
|
||
Context 'When the input contains multiple types of hyphens' { | ||
It 'Should replace all hyphens appropriately' { | ||
$result = ConvertTo-WikiSidebarLinkName -Name 'Multiple‑Hyphens-Here' # Contains both Unicode and standard hyphens | ||
$result | Should -Be 'Multiple-Hyphens Here' | ||
} | ||
} | ||
|
||
Context 'When the input does not contain hyphens' { | ||
It 'Should return the input unchanged' { | ||
$result = ConvertTo-WikiSidebarLinkName -Name 'NoHyphensHere' | ||
$result | Should -Be 'NoHyphensHere' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters