add test for History URL updating

This commit is contained in:
Muki Kiboigo
2026-04-10 07:38:21 -07:00
parent 08cd9ca799
commit d47e24ced0
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<script src="testing.js"></script>
<script id=url_updates>
{
const originalUrl = location.href;
// pushState updates the URL
history.pushState(null, '', '/test-push-path');
testing.expectEqual('/test-push-path', location.pathname);
// replaceState updates the URL
history.replaceState(null, '', '/test-replace-path');
testing.expectEqual('/test-replace-path', location.pathname);
// Restore original URL so other tests aren't affected
history.replaceState(null, '', originalUrl);
}
</script>

View File

@@ -138,4 +138,5 @@ pub const JsApi = struct {
const testing = @import("../../testing.zig");
test "WebApi: History" {
try testing.htmlRunner("history.html", .{});
try testing.htmlRunner("history_url_update.html", .{});
}