From 19bdf2816ea7f1597049345bfeb429b443fdcd94 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 28 Jun 2024 17:44:02 -0300 Subject: [PATCH] add example to fromMatrix and extendMatrix --- testing/support/matrix-utils.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/testing/support/matrix-utils.ts b/testing/support/matrix-utils.ts index aef5cf1b4dd0..a99689dbc571 100644 --- a/testing/support/matrix-utils.ts +++ b/testing/support/matrix-utils.ts @@ -7,6 +7,17 @@ const appendTitle = (title: string, config: string, value: boolean | string | nu return `${title}${title.length === 0 ? '' : '-'}${newTitle}`; }; +/** + * Create a matrix from a options + * @example + * const matrix = fromMatrix({ a: [true, false], b: [true, false] }); + * // { + * // 'a(true)-b(true)': { a: true, b: true }, + * // 'a(true)-b(false)': { a: true, b: false }, + * // 'a(false)-b(true)': { a: false, b: true }, + * // 'a(false)-b(false)': { a: false, b: false }, + * // } + */ export const fromMatrix = (configMatrix: Record) => { const configEntries = Object.entries(configMatrix); const samples = configEntries.reduce( @@ -67,6 +78,15 @@ const applyExtendedMatrix = (matrixEntries, configMatrix) => { return matrixEntries; }; +/** + * Apply new matrix value to existing matrix + * @example + * const matrix = extendMatrix(fromMatrix({ initialMatrix: [true, false] }), { toBeMerged: [true, false] }); + * // { + * // 'initialMatrix(true)-toBeMerged(true)': { initialMatrix: true, toBeMerged: true }, + * // 'initialMatrix(false)-toBeMerged(false)': { initialMatrix: false, toBeMerged: false }, + * // } + */ export const extendMatrix = (matrix, configMatrix) => { return Object.fromEntries(applyExtendedMatrix(Object.entries(matrix), configMatrix)); };