From 614ff4a5e522f94965556c979579dae1e91c234e Mon Sep 17 00:00:00 2001 From: Wolmir Nemitz Date: Tue, 12 Jul 2022 17:05:29 -0300 Subject: [PATCH] Refactor more helpers --- webview/src/test/tableDataFixture.ts | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/webview/src/test/tableDataFixture.ts b/webview/src/test/tableDataFixture.ts index 64c15fd012..d33a9d5410 100644 --- a/webview/src/test/tableDataFixture.ts +++ b/webview/src/test/tableDataFixture.ts @@ -41,23 +41,13 @@ export const transformRows = ( } as TableData } -export const setExperimentsAsStarred = ( - fixture: TableData, - labelOrIds: string[] -) => { - return transformRows(fixture, labelOrIds, row => ({ ...row, starred: true })) -} +export const setRowPropertyAsTrue = + (prop: keyof Row) => (fixture: TableData, labelOrIds: string[]) => { + return transformRows(fixture, labelOrIds, row => ({ ...row, [prop]: true })) + } -export const setExperimentsAsSelected = ( - fixture: TableData, - labelOrIds: string[] -) => { - return transformRows(fixture, labelOrIds, row => ({ ...row, selected: true })) -} +export const setExperimentsAsStarred = setRowPropertyAsTrue('starred') -export const setExperimentsAsRunning = ( - fixture: TableData, - labelOrIds: string[] -) => { - return transformRows(fixture, labelOrIds, row => ({ ...row, running: true })) -} +export const setExperimentsAsSelected = setRowPropertyAsTrue('selected') + +export const setExperimentsAsRunning = setRowPropertyAsTrue('running')