fix: types

This commit is contained in:
Andras Bacsai committed 2022-11-22 11:08:10 +01:00
1 parent 81ee438a81
commit d8e264d136
3 files changed
+21 -13

No files matched your search

+13 -11
View File
@@ -8,14 +8,16 @@ export type Page = {
id: string;
root: [string, string];
};
export type Project = {
[string]:
| {
page: Page;
tree: BaseInstance;
props: Array<UserProp> | [];
breakpoints: Array<Breakpoint> | null;
css: string;
}
| string;
};
export type Project =
| {
pages: {
[string]: {
page: Page;
tree: BaseInstance;
props: Array<UserProp> | [];
breakpoints: Array<Breakpoint> | null;
css: string;
};
};
}
| Error;
+6
View File
@@ -13,6 +13,9 @@ describe("getProjectDetails", () => {
apiUrl,
projectId: morePagesProjectId,
});
if (response instanceof Error) {
throw response;
}
expect(Object.keys(response.pages).length > 1).toBeTruthy();
});
test("does not include pages", async () => {
@@ -20,6 +23,9 @@ describe("getProjectDetails", () => {
apiUrl,
projectId: onlyHomeProjectId,
});
if (response instanceof Error) {
throw response;
}
expect(Object.keys(response.pages).length === 1).toBeTruthy();
});
test("loads existing project", async () => {
+2 -2
View File
@@ -7,7 +7,7 @@ export const loadProject = async ({
}: {
apiUrl: string;
projectId: string;
}): Promise<Project | string> => {
}): Promise<Project> => {
try {
if (apiUrl === undefined) {
throw new Error("Webstudio API URL is required.");
@@ -24,6 +24,6 @@ export const loadProject = async ({
if (error instanceof Error) {
return error;
}
return "Unknown error";
return new Error("Unknown error");
}
};