Skip to content

Commit

Permalink
Fix Should -BeLessOrEqual integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Jul 30, 2024
1 parent 5b33729 commit 72c7c63
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 6 deletions.
166 changes: 166 additions & 0 deletions tests/Integration/Syntax/v5/ShouldBeLessOrEqual.v5.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
Describe 'Should -BeLessOrEqual' {
Context 'When the tests are affirming' {
It 'Should convert `Should -BeLessOrEqual 2` correctly' {
1 | Should -BeLessOrEqual 2
}

It 'Should convert `Should -BeLessOrEqual $numericValue` correctly' {
$numericValue = 2

1 | Should -BeLessOrEqual $numericValue
}

It 'Should convert `Should -ActualValue 2 -BeLessOrEqual 2` correctly' {
Should -ActualValue 2 -BeLessOrEqual 2
}

It 'Should convert `Should -BeLessOrEqual 2 -ActualValue 2` correctly' {
Should -BeLessOrEqual 2 -ActualValue 2
}

It 'Should convert `Should -ActualValue 2 -BeLessOrEqual -ExpectedValue 2` correctly' {
Should -ActualValue 2 -BeLessOrEqual -ExpectedValue 2
}

It 'Should convert `Should -BeLessOrEqual -ActualValue 2 -ExpectedValue 2` correctly' {
Should -BeLessOrEqual -ActualValue 2 -ExpectedValue 2
}

It 'Should convert `Should -BeLessOrEqual -ExpectedValue 2 -ActualValue 2` correctly' {
Should -BeLessOrEqual -ExpectedValue 2 -ActualValue 2
}

It 'Should convert `Should -ExpectedValue 2 -BeLessOrEqual -ActualValue 2` correctly' {
Should -ExpectedValue 2 -BeLessOrEqual -ActualValue 2
}

It 'Should convert `Should -ExpectedValue 2 -ActualValue 2 -BeLessOrEqual` correctly' {
Should -ExpectedValue 2 -ActualValue 2 -BeLessOrEqual
}

It 'Should convert `Should -Not:$false -BeLessOrEqual 2` correctly' {
2 | Should -Not:$false -BeLessOrEqual 2
}

It 'Should convert `Should -BeLessOrEqual (Get-Something)` correctly' {
function Get-Something
{
return 2
}

2 | Should -BeLessOrEqual (Get-Something)
}

It 'Should convert `Should -BeLessOrEqual 2 -Because ''mock should test correct value'' 2` correctly' {
Should -BeLessOrEqual 2 -Because 'mock should test correct value' 2
}

It 'Should convert `Should -BeLessOrEqual 2 ''mock should test correct value'' 1` correctly' {
Should -BeLessOrEqual 2 'mock should test correct value' 1
}

It 'Should convert `Should 2 ''mock should test correct value'' 1 -BeLessOrEqual` correctly' {
Should 2 'mock should test correct value' 1 -BeLessOrEqual
}
}

Context 'When the tests are negated' {
It 'Should convert `Should -Not -BeLessOrEqual 2` correctly' {
3 | Should -Not -BeLessOrEqual 2
}

It 'Should convert `Should -BeLessOrEqual 2 -Not` correctly' {
3 | Should -BeLessOrEqual 2 -Not
}

It 'Should convert `Should -Not -BeLessOrEqual $anyValue` correctly' {
$anyValue = 2

3 | Should -Not -BeLessOrEqual $anyValue
}

It 'Should convert `Should -BeLessOrEqual $anyValue -Not` correctly' {
$anyValue = 2

3 | Should -BeLessOrEqual $anyValue -Not
}

It 'Should convert `Should -Not:$true -BeLessOrEqual 2` correctly' {
2 | Should -Not:$true -BeLessOrEqual 2
}

It 'Should convert `Should -Not -ActualValue 3 -BeLessOrEqual 2` correctly' {
Should -Not -ActualValue 3 -BeLessOrEqual 2
}

It 'Should convert `Should -ActualValue 3 -Not -BeLessOrEqual 2` correctly' {
Should -ActualValue 3 -Not -BeLessOrEqual 2
}

It 'Should convert `Should -ActualValue 3 -BeLessOrEqual 2 -Not` correctly' {
Should -ActualValue 3 -BeLessOrEqual 2 -Not
}

It 'Should convert `Should -BeLessOrEqual 2 -ActualValue 3 -Not` correctly' {
Should -BeLessOrEqual 2 -ActualValue 3 -Not
}

It 'Should convert `Should -BeLessOrEqual 2 -Not -ActualValue 3` correctly' {
Should -BeLessOrEqual 2 -Not -ActualValue 3
}

It 'Should convert `Should -Not -BeLessOrEqual 2 -ActualValue 3` correctly' {
Should -Not -BeLessOrEqual 2 -ActualValue 3
}

It 'Should convert `Should -ActualValue 3 -BeLessOrEqual -Not -ExpectedValue 2` correctly' {
Should -ActualValue 3 -BeLessOrEqual -Not -ExpectedValue 2
}

It 'Should convert `Should -ActualValue 3 -Not -BeLessOrEqual -ExpectedValue 2` correctly' {
Should -ActualValue 3 -Not -BeLessOrEqual -ExpectedValue 2
}

It 'Should convert `Should -ActualValue 3 -BeLessOrEqual -ExpectedValue 2 -Not` correctly' {
Should -ActualValue 3 -BeLessOrEqual -ExpectedValue 2 -Not
}
}

Context 'When alias operator name is used' {
It 'Should convert `Should -LE 2 -ActualValue 1` correctly' {
Should -LE 2 -ActualValue 1
}
}

Context 'When tests should always use named parameters' {
It 'Should convert `Should -BeLessOrEqual 2 -ActualValue 1` correctly' {
Should -BeLessOrEqual 2 -ActualValue 1
}
}

Context 'When tests should always use positional parameters' {
Context 'When the tests are affirming' {
It 'Should convert `Should -BeLessOrEqual 2 -ActualValue 1` correctly' {
Should -BeLessOrEqual 2 -ActualValue 1
}

It 'Should convert `Should -BeLessOrEqual 2 -ActualValue 1 -Because "this must return true"` correctly' {
Should -BeLessOrEqual 2 -ActualValue 1 -Because 'this must return true'
}

It 'Should convert `Should -BeLessOrEqual 2 -Because "this must return true" -ActualValue 1` correctly' {
Should -BeLessOrEqual 2 -Because 'this must return true' -ActualValue 1
}

It 'Should convert `Should -Because "this must return true" -ActualValue 1 -BeLessOrEqual 2` correctly' {
Should -Because 'this must return true' -ActualValue 1 -BeLessOrEqual 2
}
}

Context 'When the tests are negated' {
It 'Should convert `Should -BeLessOrEqual 2 -ActualValue 3 -Because "this must return true" -Not` correctly' {
Should -BeLessOrEqual 2 -ActualValue 3 -Because 'this must return true' -Not
}
}
}
}
12 changes: 6 additions & 6 deletions tests/Unit/Private/Convert-ShouldBeLessOrEqual.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Describe 'Convert-ShouldBeLessOrEqual' {
It 'Should convert `Should -Not:$false -BeLessOrEqual 2` correctly' {
InModuleScope -ScriptBlock {
$mockCommandAstPester5 = {
$false | Should -Not:$false -BeLessOrEqual 2
2 | Should -Not:$false -BeLessOrEqual 2
}.Ast.Find({ $args[0] -is [System.Management.Automation.Language.CommandAst] }, $false)

$result = Convert-ShouldBeLessOrEqual -CommandAst $mockCommandAstPester5
Expand Down Expand Up @@ -202,10 +202,10 @@ Describe 'Convert-ShouldBeLessOrEqual' {
}
}

It 'Should convert `Should -BeLessOrEqual 2 ''mock should test correct value'' 3` correctly' {
It 'Should convert `Should -BeLessOrEqual 2 ''mock should test correct value'' 1` correctly' {
InModuleScope -ScriptBlock {
$mockCommandAstPester5 = {
Should -BeLessOrEqual 2 'mock should test correct value' 3
Should -BeLessOrEqual 2 'mock should test correct value' 1
}.Ast.Find({ $args[0] -is [System.Management.Automation.Language.CommandAst] }, $false)

$result = Convert-ShouldBeLessOrEqual -CommandAst $mockCommandAstPester5
Expand All @@ -214,10 +214,10 @@ Describe 'Convert-ShouldBeLessOrEqual' {
}
}

It 'Should convert `Should 2 ''mock should test correct value'' 3 -BeLessOrEqual` correctly' {
It 'Should convert `Should 2 ''mock should test correct value'' 1 -BeLessOrEqual` correctly' {
InModuleScope -ScriptBlock {
$mockCommandAstPester5 = {
Should 2 'mock should test correct value' 3 -BeLessOrEqual
Should 2 'mock should test correct value' 1 -BeLessOrEqual
}.Ast.Find({ $args[0] -is [System.Management.Automation.Language.CommandAst] }, $false)

$result = Convert-ShouldBeLessOrEqual -CommandAst $mockCommandAstPester5
Expand Down Expand Up @@ -279,7 +279,7 @@ Describe 'Convert-ShouldBeLessOrEqual' {
It 'Should convert `Should -Not:$true -BeLessOrEqual 2` correctly' {
InModuleScope -ScriptBlock {
$mockCommandAstPester5 = {
$false | Should -Not:$true -BeLessOrEqual 2
2 | Should -Not:$true -BeLessOrEqual 2
}.Ast.Find({ $args[0] -is [System.Management.Automation.Language.CommandAst] }, $false)

$result = Convert-ShouldBeLessOrEqual -CommandAst $mockCommandAstPester5
Expand Down

0 comments on commit 72c7c63

Please sign in to comment.