@ithaka/bonsai
Version:
ITHAKA core styling
24 lines (18 loc) • 964 B
JavaScript
import { updateUrlParameter } from "../urls";
describe("Update Url Parameter Tests", function() {
test("updateUrlParameter when supplied parameter present", function() {
expect(updateUrlParameter("/?bar=baz", "bar", "qux")).toBe("/?bar=qux");
});
test("updateUrlParameter when no parameters present", function() {
expect(updateUrlParameter("/", "bar", "baz")).toBe("/?bar=baz");
});
test("updateUrlParameter when parameters present without supplied parameter", function() {
expect(updateUrlParameter("/?bar=baz", "qux", "quux")).toBe("/?bar=baz&qux=quux");
});
test("updateUrlParameter when supplied key needs encoding", function() {
expect(updateUrlParameter("/", "bar baz", "qux")).toBe("/?bar%20baz=qux");
});
test("updateUrlParameter when supplied value needs encoding", function() {
expect(updateUrlParameter("/?bar=baz", "bar", "baz qux")).toBe("/?bar=baz%20qux");
});
});