Skip to content

Commit 8a1c705

Browse files
committed
Pester updated 3.4.0=>5.7.1
1 parent 5e4c5f6 commit 8a1c705

File tree

5 files changed

+74
-58
lines changed

5 files changed

+74
-58
lines changed

Tests/Integration/Projects.Tests.ps1

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
Import-Module -Name Pester -Force
1+
if (-not (Get-Module -Name Pester)) {
2+
Import-Module -Name Pester -Force
3+
}
24
Import-Module .\Toggl.API\Toggl.API.psm1 -Force
35

4-
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
5-
$config = Get-Content -Path $configPath | ConvertFrom-Json
6+
Describe 'Toggl Projects Integration Tests' {
7+
BeforeAll {
8+
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
9+
$config = Get-Content -Path $configPath | ConvertFrom-Json
610

7-
$apiToken = $config.apiToken
8-
$workspaceId = $config.workspaceId
11+
$apiToken = $config.apiToken
12+
$workspaceId = $config.workspaceId
913

10-
Describe 'Toggl Projects Integration Tests' {
11-
$projectName = "TestProjectToRemove"
12-
$projectId = $null
14+
$projectName = "TestProjectToRemove"
15+
$projectId = $null
16+
}
1317

1418
Context "New-TogglProject" {
1519
It "should create a new project in the workspace" {
@@ -43,20 +47,20 @@ Describe 'Toggl Projects Integration Tests' {
4347
Context "Remove-TogglProject" {
4448
It "should delete the project from the workspace" -Skip:($Script:projectId -eq $null) {
4549
Remove-TogglProject `
46-
-ApiToken $apiToken `
47-
-WorkspaceId $workspaceId `
48-
-ProjectId $Script:projectId
50+
-ApiToken $apiToken `
51+
-WorkspaceId $workspaceId `
52+
-ProjectId $Script:projectId
4953

5054
# Verify the project was deleted
5155
$projects = Get-TogglProjects `
52-
-ApiToken $apiToken `
53-
-WorkspaceId $workspaceId `
54-
-SortPinned $true `
55-
-Name $projectName `
56-
-Page 1 `
57-
-SortField "name" `
58-
-SortOrder "asc" `
59-
-OnlyTemplates $false
56+
-ApiToken $apiToken `
57+
-WorkspaceId $workspaceId `
58+
-SortPinned $true `
59+
-Name $projectName `
60+
-Page 1 `
61+
-SortField "name" `
62+
-SortOrder "asc" `
63+
-OnlyTemplates $false
6064
$projects | Where-Object { $_.id -eq $Script:projectId } | Should BeNullOrEmpty
6165
}
6266
}

Tests/Integration/Reports.Detailed.Tests.ps1

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
Import-Module -Name Pester -Force
1+
if (-not (Get-Module -Name Pester)) {
2+
Import-Module -Name Pester -Force
3+
}
24
Import-Module .\Toggl.API\Toggl.API.psm1 -Force
35

4-
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
5-
$config = Get-Content -Path $configPath | ConvertFrom-Json
6+
Describe 'Reports.Detailed Integration Tests' {
7+
BeforeAll {
8+
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
9+
$config = Get-Content -Path $configPath | ConvertFrom-Json
610

7-
$apiToken = $config.apiToken
8-
$workspaceId = $config.workspaceId
11+
$apiToken = $config.apiToken
12+
$workspaceId = $config.workspaceId
913

10-
$startDate = "2023-01-01"
11-
$endDate = "2023-12-31"
14+
$startDate = "2023-01-01"
15+
$endDate = "2023-12-31"
1216

13-
Describe 'Reports.Detailed Integration Tests' {
14-
BeforeAll {
1517
$timeEntryIds = @()
1618
$tagIds = @()
1719
$start = [datetime]::ParseExact("2023-01-01", "yyyy-MM-dd", $null)
@@ -25,7 +27,7 @@ Describe 'Reports.Detailed Integration Tests' {
2527
-Start $start `
2628
-Description "Test Time Entry 1"
2729

28-
$response1 | Should Not BeNullOrEmpty
30+
$response1 | Should -Not -BeNullOrEmpty
2931
$timeEntryIds += $response1.id
3032

3133
# Create second time entry
@@ -36,7 +38,7 @@ Describe 'Reports.Detailed Integration Tests' {
3638
-Start $start `
3739
-Description "Test Time Entry 2"
3840

39-
$response2 | Should Not BeNullOrEmpty
41+
$response2 | Should -Not -BeNullOrEmpty
4042
$timeEntryIds += $response2.id
4143

4244
$response3 = New-TogglTimeEntry `
@@ -47,7 +49,7 @@ Describe 'Reports.Detailed Integration Tests' {
4749
-Description "Test Time Entry 3" `
4850
-Tags @("tag1", "tag2")
4951

50-
$response3 | Should Not BeNullOrEmpty
52+
$response3 | Should -Not -BeNullOrEmpty
5153
$timeEntryIds += $response3.id
5254
$tagIds += $response3.tag_ids
5355
}
@@ -71,7 +73,7 @@ Describe 'Reports.Detailed Integration Tests' {
7173
-EndDate $endDate `
7274
-PageSize 10
7375

74-
$response | Should Not BeNullOrEmpty
76+
$response | Should -Not -BeNullOrEmpty
7577
$response.GetType().Name | Should -Be "Object[]"
7678
$response.Count | Should -BeExactly $timeEntryIds.Count
7779

@@ -93,11 +95,11 @@ Describe 'Reports.Detailed Integration Tests' {
9395
-TagIds @() `
9496
-PageSize 10
9597

96-
$response | Should Not BeNullOrEmpty
98+
$response | Should -Not -BeNullOrEmpty
9799
$response.GetType().Name | Should -Be "Object[]"
98100

99101
$response | ForEach-Object {
100-
$_.tags | Should BeNullOrEmpty
102+
$_.tags | Should -BeNullOrEmpty
101103
}
102104
}
103105

@@ -110,7 +112,7 @@ Describe 'Reports.Detailed Integration Tests' {
110112
-TagIds $tagIds `
111113
-PageSize 10
112114

113-
$response | Should Not BeNullOrEmpty
115+
$response | Should -Not -BeNullOrEmpty
114116

115117
$response.GetType().Name | Should -Be "PSCustomObject"
116118

Tests/Integration/Tags.Tests.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
Import-Module -Name Pester -Force
1+
if (-not (Get-Module -Name Pester)) {
2+
Import-Module -Name Pester -Force
3+
}
24
Import-Module .\Toggl.API\Toggl.API.psm1 -Force
35

4-
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
5-
$config = Get-Content -Path $configPath | ConvertFrom-Json
6+
Describe 'Toggl Tag Integration Tests' {
7+
BeforeAll {
8+
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
9+
$config = Get-Content -Path $configPath | ConvertFrom-Json
610

7-
$apiToken = $config.apiToken
8-
$workspaceId = $config.workspaceId
11+
$apiToken = $config.apiToken
12+
$workspaceId = $config.workspaceId
913

10-
Describe 'Toggl Tag Integration Tests' {
11-
$tagName = "TestTagToRemove"
14+
$tagName = "TestTagToRemove"
15+
}
1216

1317
Context "New-TogglTag" {
1418
It "should create a new tag in the workspace" {

Tests/Integration/TimeEntries.Tests.ps1

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
Import-Module -Name Pester -Force
1+
if (-not (Get-Module -Name Pester)) {
2+
Import-Module -Name Pester -Force
3+
}
24
Import-Module .\Toggl.API\Toggl.API.psm1 -Force
35

4-
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
5-
$config = Get-Content -Path $configPath | ConvertFrom-Json
6+
Describe 'TimeEntries Integration Tests' {
7+
BeforeAll {
8+
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "..\config.json"
9+
$config = Get-Content -Path $configPath | ConvertFrom-Json
610

7-
$apiToken = $config.apiToken
8-
$workspaceId = $config.workspaceId
11+
$apiToken = $config.apiToken
12+
$workspaceId = $config.workspaceId
913

10-
Describe 'TimeEntries Integration Tests' {
11-
$timeEntryId = $null
14+
$timeEntryId = $null
15+
}
1216

1317
Context "New-TogglTimeEntry" {
1418
It "should create a new time entry" {
@@ -23,7 +27,7 @@ Describe 'TimeEntries Integration Tests' {
2327
-Start $start `
2428
-Description $description
2529

26-
$response | Should Not BeNullOrEmpty
30+
$response | Should -Not -BeNullOrEmpty
2731
$response.description | Should -BeExactly $description
2832
$Script:timeEntryId = $response.id
2933
}
@@ -35,7 +39,7 @@ Describe 'TimeEntries Integration Tests' {
3539
-ApiToken $apiToken `
3640
-TimeEntryId $Script:timeEntryId
3741

38-
$response | Should Not BeNullOrEmpty
42+
$response | Should -Not -BeNullOrEmpty
3943
$response.id | Should -BeExactly $Script:timeEntryId
4044
}
4145

@@ -46,7 +50,7 @@ Describe 'TimeEntries Integration Tests' {
4650
-ApiToken $apiToken `
4751
-TimeEntryId $nonExistingTimeEntryId
4852

49-
$response | Should BeNullOrEmpty
53+
$response | Should -BeNullOrEmpty
5054
}
5155
}
5256

@@ -71,11 +75,11 @@ Describe 'TimeEntries Integration Tests' {
7175
-ApiToken $apiToken `
7276
-Since ([int][double]::Parse((Get-Date).AddDays(-7).ToUniversalTime().Subtract([datetime]'1970-01-01').TotalSeconds))
7377

74-
$response | Should Not BeNullOrEmpty
78+
$response | Should -Not -BeNullOrEmpty
7579
$response.GetType().Name | Should -Be "Object[]"
7680

7781
$filteredResponse = $response | Where-Object { $_.server_deleted_at -ne $null }
78-
$filteredResponse | Should Not BeNullOrEmpty
82+
$filteredResponse | Should -Not -BeNullOrEmpty
7983
$filteredResponse.Count | Should -BeGreaterThan 0
8084
}
8185
}
@@ -91,7 +95,7 @@ Describe 'TimeEntries Integration Tests' {
9195
-ApiToken $apiToken `
9296
-TimeEntryId $Script:timeEntryId
9397

94-
$response | Should BeNullOrEmpty
98+
$response | Should -BeNullOrEmpty
9599
}
96100
}
97101
}

Tests/Toggl.API.Tests.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Import-Module -Name Pester -Force
1+
if (-not (Get-Module -Name Pester)) {
2+
Import-Module -Name Pester -Force
3+
}
24
Import-Module .\Toggl.API\Toggl.API.psm1 -Force
35

46
Describe 'Toggl.API.Tests' {
@@ -9,15 +11,15 @@ Describe 'Toggl.API.Tests' {
911

1012
$header = Get-TogglAuthHeader -ApiToken 123a12abcd1ab1234d86a471e916295c
1113
$header.ContainsKey('Authorization') | Should -Be $true
12-
$header.Authorization | Should Not BeNullOrEmpty
14+
$header.Authorization | Should -Not -BeNullOrEmpty
1315
$header.Authorization | Should -BeExactly $expected
1416
}
1517

1618
It "given apiToken=<apiToken>, it throws exception" -TestCases @(
1719
@{ apiToken = "" }
1820
@{ apiToken = $null }
1921
) {
20-
{ Get-TogglAuthHeader -ApiToken '' } | Should Throw "Cannot bind argument to parameter 'ApiToken' because it is an empty string."
22+
{ Get-TogglAuthHeader -ApiToken '' } | Should -Throw "Cannot bind argument to parameter 'ApiToken' because it is an empty string."
2123
}
2224
}
2325
}

0 commit comments

Comments
 (0)