mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'ForEach-Object' (alias is '%' or 'foreach') - Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'Where-Object' (alias is '?' or 'where') - Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'Select-Object' (alias is 'select') - Fix PSScriptAnalyzer warnings of type PSPossibleIncorrectComparisonWithNull. Essentially, $null has to be on the left-hand side when using it for comparison. - A Test in ParameterBinding.Tests.ps1 needed adapting as this test used to rely on the wrong null comparison - Replace a subset of tests of kind '($object -eq $null) | Should Be $true' with '$object | Should Be $null'
54 lines
2.0 KiB
PowerShell
54 lines
2.0 KiB
PowerShell
Describe "PSReadLine" -tags "CI" {
|
|
BeforeAll {
|
|
if (Get-Module PSReadLine) {
|
|
$originalEditMode = (Get-PSReadLineOption).EditMode
|
|
Remove-Module PSReadLine
|
|
}
|
|
}
|
|
|
|
It "Should import the module correctly" {
|
|
Import-Module PSReadLine
|
|
$module = Get-Module PSReadLine
|
|
$module.Name | Should Be "PSReadLine"
|
|
$module.Version | Should Be "1.2"
|
|
}
|
|
|
|
It "Should use Emacs Bindings on Linux and OS X" -skip:$IsWindows {
|
|
(Get-PSReadLineOption).EditMode | Should Be Emacs
|
|
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should Be BeginningOfLine
|
|
}
|
|
|
|
It "Should use Windows Bindings on Windows" -skip:(-not $IsWindows) {
|
|
(Get-PSReadLineOption).EditMode | Should Be Windows
|
|
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+a" }).Function | Should Be SelectAll
|
|
}
|
|
|
|
It "Should set the edit mode" {
|
|
Set-PSReadlineOption -EditMode Windows
|
|
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should Be SelectAll
|
|
|
|
Set-PSReadlineOption -EditMode Emacs
|
|
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should Be BeginningOfLine
|
|
}
|
|
|
|
It "Should allow custom bindings for plain keys" {
|
|
Set-PSReadlineKeyHandler -Key '"' -Function SelfInsert
|
|
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq '"' }).Function | Should Be SelfInsert
|
|
}
|
|
|
|
It "Should report Capitalized bindings correctly" {
|
|
Set-PSReadlineOption -EditMode Emacs
|
|
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+b" }).Function | Should Be BackwardWord
|
|
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+B" }).Function | Should Be SelectBackwardWord
|
|
}
|
|
|
|
AfterAll {
|
|
Remove-Module PSReadLine
|
|
|
|
if ($originalEditMode) {
|
|
Import-Module PSReadLine
|
|
Set-PSReadlineOption -EditMode $originalEditMode
|
|
}
|
|
}
|
|
}
|