fleet/frontend/utilities/url/url.tests.ts
Gabriel Hernandez aa60f3a54f
cleanup of manage host page utilities (#7055)
* colocate LabelForm with ManageHostPage

* add url utility to create query string from params object
2022-08-05 09:27:10 -04:00

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");
});
});