mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
aa60f3a54f
* colocate LabelForm with ManageHostPage * add url utility to create query string from params object
43 lines
984 B
TypeScript
43 lines
984 B
TypeScript
import { buildQueryStringFromParams } from ".";
|
|
|
|
describe("url utilites", () => {
|
|
it("creates a query string from a params object", () => {
|
|
const params = {
|
|
query: "test",
|
|
page: 1,
|
|
order: "asc",
|
|
isNew: true,
|
|
};
|
|
expect(buildQueryStringFromParams(params)).toBe(
|
|
"query=test&page=1&order=asc&isNew=true"
|
|
);
|
|
});
|
|
|
|
it("filters out undefined values", () => {
|
|
const params = {
|
|
query: undefined,
|
|
page: 1,
|
|
order: "asc",
|
|
};
|
|
expect(buildQueryStringFromParams(params)).toBe("page=1&order=asc");
|
|
});
|
|
|
|
it("filters out empty string values", () => {
|
|
const params = {
|
|
query: "",
|
|
page: 1,
|
|
order: "asc",
|
|
};
|
|
expect(buildQueryStringFromParams(params)).toBe("page=1&order=asc");
|
|
});
|
|
|
|
it("filters out null values", () => {
|
|
const params = {
|
|
query: null,
|
|
page: 1,
|
|
order: "asc",
|
|
};
|
|
expect(buildQueryStringFromParams(params)).toBe("page=1&order=asc");
|
|
});
|
|
});
|