Initial Commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import { navigateOrCall } from "./navigate-or-call.js";
|
||||
|
||||
describe("navigateOrCall", () => {
|
||||
it("invokes a function target", { timeout: 5000 }, () => {
|
||||
let called = 0;
|
||||
navigateOrCall(() => {
|
||||
called += 1;
|
||||
});
|
||||
expect(called).toBe(1);
|
||||
});
|
||||
|
||||
it("writes window.location.href when target is a string", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const original = window.location.href;
|
||||
navigateOrCall("https://example.com/somewhere");
|
||||
expect(window.location.href).not.toBe(original);
|
||||
});
|
||||
|
||||
it("is a no-op for undefined target", { timeout: 5000 }, () => {
|
||||
expect(() => navigateOrCall(undefined)).not.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user