Skip to content

Commit

Permalink
Add assertion tests
Browse files Browse the repository at this point in the history
- Tests for when connected via `Connect-Zendesk`
- Tests for when not connected.
  • Loading branch information
RobFaie committed Mar 15, 2020
1 parent cc154c7 commit 8cb702f
Showing 1 changed file with 113 additions and 3 deletions.
116 changes: 113 additions & 3 deletions tests/Assertions.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Describe 'Users Routes' {
}
$context | Add-Member -TypeName 'ZendeskContext'

Context 'Admin' {
Context 'Admin with context' {

$context.User.role = 'admin'

Expand Down Expand Up @@ -45,7 +45,7 @@ Describe 'Users Routes' {

}

Context 'Agent' {
Context 'Agent with context' {

$context.User.role = 'agent'

Expand Down Expand Up @@ -75,7 +75,7 @@ Describe 'Users Routes' {

}

Context 'End User' {
Context 'End User with context' {

$context.User.role = 'end-user'

Expand Down Expand Up @@ -105,6 +105,116 @@ Describe 'Users Routes' {

}

$Script:Context = $context
Remove-Variable -Name context

Context 'Admin while connected' {

$Script:Context.User.role = 'admin'

It 'Test-IsAdmin => $true' {
Test-IsAdmin | Should -Be $true
}

It 'Test-IsAgent => $false' {
Test-IsAgent | Should -Be $false
}

It 'Test-IsEndUser => $false' {
Test-IsEndUser | Should -Be $false
}

It 'Assert-IsAdmin passes' {
{ Assert-IsAdmin } | Should -Not -Throw
}

It 'Assert-IsAgent passes' {
{ Assert-IsAgent } | Should -Not -Throw
}

It 'Assert-IsEndUser throws' {
{ Assert-IsEndUser } | Should -Throw
}

}

Context 'Agent while connected' {

$Script:Context.User.role = 'agent'

It 'Test-IsAdmin => $false' {
Test-IsAdmin | Should -Be $false
}

It 'Test-IsAgent => $true' {
Test-IsAgent | Should -Be $true
}

It 'Test-IsEndUser => $false' {
Test-IsEndUser | Should -Be $false
}

It 'Assert-IsAdmin throw' {
{ Assert-IsAdmin } | Should -Throw
}

It 'Assert-IsAgent passes' {
{ Assert-IsAgent } | Should -Not -Throw
}

It 'Assert-IsEndUser throws' {
{ Assert-IsEndUser } | Should -Throw
}

}

Context 'End User while connected' {

$Script:Context.User.role = 'end-user'

It 'Test-IsAdmin => $false' {
Test-IsAdmin | Should -Be $false
}

It 'Test-IsAgent => $false' {
Test-IsAgent | Should -Be $false
}

It 'Test-IsEndUser => $true' {
Test-IsEndUser | Should -Be $true
}

It 'Assert-IsAdmin throws' {
{ Assert-IsAdmin } | Should -Throw
}

It 'Assert-IsAgent throws' {
{ Assert-IsAgent } | Should -Throw
}

It 'Assert-IsEndUser passes' {
{ Assert-IsEndUser } | Should -Not -Throw
}

}

Context 'Not connected' {

Remove-Variable -Name Context -Scope Script

It 'Assert-IsAdmin throws' {
{ Assert-IsAdmin } | Should -Throw 'No connection supplied'
}

It 'Assert-IsAgent throws' {
{ Assert-IsAgent } | Should -Throw 'No connection supplied'
}

It 'Assert-IsEndUser throws' {
{ Assert-IsEndUser } | Should -Throw 'No connection supplied'
}
}

}

}

0 comments on commit 8cb702f

Please sign in to comment.