* 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
48 lines
1.3 KiB
TypeScript
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",
|
|
});
|
|
});
|
|
});
|