From d9bd2f8a6450442ad70e9b329701bd69cd36a95d Mon Sep 17 00:00:00 2001 From: Bernardo Raposo Date: Wed, 11 Sep 2019 00:40:12 +0100 Subject: [PATCH] fix: fix issues with failing tests --- src/utils/figma.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/figma.ts b/src/utils/figma.ts index 62eed1b..c218d03 100644 --- a/src/utils/figma.ts +++ b/src/utils/figma.ts @@ -64,6 +64,7 @@ const mapTypeToFunctionWithParams = { }; const mapTypeToFunction = { + [RequestType.File]: file, [RequestType.Comments]: comments, [RequestType.Projects]: teamProjects, [RequestType.ProjectFiles]: projectFiles, @@ -114,7 +115,7 @@ async function getFigma({ console.log("fetching", key); const fn: FigmaFunction = - params !== undefined + params === undefined ? mapTypeToFunction[requestType] : mapTypeToFunctionWithParams[requestType]; @@ -122,7 +123,10 @@ async function getFigma({ const { data } = await fn(id, { ...params }); // We just need to parse the response if it's for a file, otherwise we return the raw data - const processedData = "document" in data ? buildCustomFileReponse(data, id) : data; + const processedData = + "document" in data && requestType === RequestType.File + ? buildCustomFileReponse(data, id) + : data; // Only store data that doesn't change depending on the params // We store it even if noCache is true so we can update the cache @@ -132,7 +136,7 @@ async function getFigma({ return processedData as T; } catch (e) { - throw new Error("Problem fetching data"); + throw new Error(e); } }