fal-js/libs/client/src/utils.spec.ts
Daniel Rochetti 543b9208eb
feat: 1.0.0 release (#91)
* chore(client): rename function module

* chore: allow client to be created multiple times

singleton client is not the default but it still present as a compatibility layer

* chore: update docs

* feat(client): improved result typing

* chore: update demo app code

* chore: updated reference docs

* chore: update proxy code

* chore: alpha release

* chore: fix lint staged rule

* chore: clean-up docs

* chore: reference docs updated
2024-10-07 12:54:30 -07:00

48 lines
1.3 KiB
TypeScript

import { ensureEndpointIdFormat, parseEndpointId } from "./utils";
describe("The utils test suite", () => {
it("shoud match a current appOwner/appId format", () => {
const id = "fal-ai/fast-sdxl";
expect(ensureEndpointIdFormat(id)).toBe(id);
});
it("shoud match a current appOwner/appId/path format", () => {
const id = "fal-ai/fast-sdxl/image-to-image";
expect(ensureEndpointIdFormat(id)).toBe(id);
});
it("should throw on an invalid app id format", () => {
const id = "just-an-id";
expect(() => ensureEndpointIdFormat(id)).toThrowError();
});
it("should parse a current app id", () => {
const id = "fal-ai/fast-sdxl";
const parsed = parseEndpointId(id);
expect(parsed).toEqual({
owner: "fal-ai",
alias: "fast-sdxl",
});
});
it("should parse a current app id with path", () => {
const id = "fal-ai/fast-sdxl/image-to-image";
const parsed = parseEndpointId(id);
expect(parsed).toEqual({
owner: "fal-ai",
alias: "fast-sdxl",
path: "image-to-image",
});
});
it("should parse a current app id with namespace", () => {
const id = "workflows/fal-ai/fast-sdxl";
const parsed = parseEndpointId(id);
expect(parsed).toEqual({
owner: "fal-ai",
alias: "fast-sdxl",
namespace: "workflows",
});
});
});