mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
ref
This commit is contained in:
@@ -1,4 +1,52 @@
|
||||
import { takeWithRepeats } from "../src/utils";
|
||||
import { asURLSearchParams, takeWithRepeats } from "../src/utils";
|
||||
|
||||
describe("asURLSearchParams", () => {
|
||||
describe("empty q", () => {
|
||||
it("should return empty params", () => {
|
||||
const q = {};
|
||||
const expected = new URLSearchParams();
|
||||
expect(asURLSearchParams(q)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("singular params", () => {
|
||||
it("should append each", () => {
|
||||
const q = {
|
||||
a: 1,
|
||||
b: "bee",
|
||||
c: false,
|
||||
d: true,
|
||||
};
|
||||
const expected = new URLSearchParams();
|
||||
expected.append("a", "1");
|
||||
expected.append("b", "bee");
|
||||
expected.append("c", "false");
|
||||
expected.append("d", "true");
|
||||
|
||||
expect(asURLSearchParams(q)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("list params", () => {
|
||||
it("should append each", () => {
|
||||
const q = {
|
||||
a: [1, "two", false, true],
|
||||
b: "yippee",
|
||||
};
|
||||
|
||||
const expected = new URLSearchParams();
|
||||
expected.append("a", "1");
|
||||
expected.append("a", "two");
|
||||
expected.append("a", "false");
|
||||
expected.append("a", "true");
|
||||
expected.append("b", "yippee");
|
||||
|
||||
expect(asURLSearchParams(q)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe("takeWithRepeat", () => {
|
||||
describe("when there is nothing in the input", () => {
|
||||
|
||||
Reference in New Issue
Block a user