From da2d6bfc80885b00c0c4ccb9dcba19c2e518d16a Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 4 May 2016 14:42:04 -0700 Subject: [PATCH] Add PSReadLine regression tests --- test/powershell/PSReadLine.Tests.ps1 | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/powershell/PSReadLine.Tests.ps1 diff --git a/test/powershell/PSReadLine.Tests.ps1 b/test/powershell/PSReadLine.Tests.ps1 new file mode 100644 index 000000000..7821fca3e --- /dev/null +++ b/test/powershell/PSReadLine.Tests.ps1 @@ -0,0 +1,32 @@ +Describe "PSReadLine" { + 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 set the edit mode" { + Set-PSReadlineOption -EditMode Windows + (Get-PSReadlineKeyHandler | where { $_.Key -eq "Ctrl+A" }).Function | Should Be SelectAll + + Set-PSReadlineOption -EditMode Emacs + (Get-PSReadlineKeyHandler | where { $_.Key -eq "Ctrl+A" }).Function | Should Be BeginningOfLine + } + + AfterAll { + Remove-Module PSReadLine + + if ($originalEditMode) { + Import-Module PSReadLine + Set-PSReadlineOption -EditMode $originalEditMode + } + } +}