tuitio-client/src/__tests__/Utils.test.ts

27 lines
752 B
TypeScript
Raw Normal View History

import { combineUrls, isValidURL } from "../utils";
test("Combine urls with trailing slash", () => {
const result = combineUrls("https://test.com/api/", "/test");
expect(result).toBe("https://test.com/api/test");
});
test("Combine urls without trailing slash", () => {
const result = combineUrls("https://test.com/api", "/test");
expect(result).toBe("https://test.com/api/test");
});
test("Check valid https URL", () => {
const result = isValidURL("https://test.com/api");
expect(result).toBe(true);
});
test("Check valid http URL", () => {
const result = isValidURL("http://test.com/api");
expect(result).toBe(true);
});
test("Check invalid URL", () => {
const result = isValidURL("test/api");
expect(result).toBe(false);
});