Skip to content

Commit 9ddb9af

Browse files
author
James Brundage
committed
test: Start-Htmx ( Fixes #7 )
Waiting for job to start before returning
1 parent 8191033 commit 9ddb9af

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Commands/Start-Htmx.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,16 @@ function Start-Htmx {
470470

471471
# If we haven't determined the server URL, we will do so now.
472472
if (-not $serverJob.ServerUrl) {
473-
$prefixes = $HttpListener.Prefixes -as [string[]]
473+
$prefixes = $HttpListener.Prefixes -as [string[]]
474474
$ServerUrl = $prefixes[0]
475475
$serverJob.psobject.properties.add(
476476
[psnoteproperty]::new('ServerUrl', $ServerUrl), $true
477477
)
478478
}
479479

480+
while ($serverJob.JobStateInfo.State -eq 'NotStarted') {
481+
Start-Sleep -Milliseconds (Get-Random -Maximum 20 -Minimum 1)
482+
}
480483
$serverJob
481484
}
482485
}

HtmxPS.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe HtmxPS {
2424
$startedLocalJob = Start-Htmx -Htmx (
2525
htmx button "Click Me" hx-on:click="alert('Thanks, I needed that!')"
2626
) -ServerUrl "http://127.0.0.1:8080/"
27-
Start-Sleep -Seconds 1
27+
# Start-Sleep -Seconds 1
2828
Invoke-RestMethod -Uri $startedLocalJob.ServerUrl
2929
$startedLocalJob | Stop-Htmx
3030
$startedLocalJob | Remove-Job

0 commit comments

Comments
 (0)