From de631e42dfbadda93768e77ed9143b3d84cc32de Mon Sep 17 00:00:00 2001 From: Bryan Thomas <49354825+bryanjtc@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:22:44 -0500 Subject: [PATCH] refactor(transformCsf): Simplify makePlayTest function and remove unnecessary conditional The makePlayTest function in the transformCsf file has been simplified to remove an unnecessary conditional statement. The metaOrStoryPlay parameter is now optional, indicated by the use of the "?" symbol. This change was made to improve code readability and reduce complexity. --- src/csf/transformCsf.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/csf/transformCsf.ts b/src/csf/transformCsf.ts index be5f3503..7a941702 100644 --- a/src/csf/transformCsf.ts +++ b/src/csf/transformCsf.ts @@ -66,7 +66,7 @@ const makePlayTest = ({ }: { key: string; title: string; - metaOrStoryPlay: t.Node; + metaOrStoryPlay?: t.Node; testPrefix?: TestPrefixer; shouldSkip?: boolean; }): t.Statement[] => { @@ -147,22 +147,17 @@ export const transformCsf = ( .map((key: string) => { let tests: t.Statement[] = []; const shouldSkip = skipTags.some((tag) => storyAnnotations[key].tags?.includes(tag)); - const playFunctions = storyAnnotations[key]?.play; if (title) { tests = [ ...tests, - ...(playFunctions !== undefined - ? [ - makePlayTest({ - key, - title, - metaOrStoryPlay: playFunctions, - testPrefix: testPrefixer, - shouldSkip, - }), - ] - : []), - ].flat(); + ...makePlayTest({ + key, + title, + metaOrStoryPlay: storyAnnotations[key]?.play, + testPrefix: testPrefixer, + shouldSkip, + }), + ]; } if (tests.length) {