From 881931134ad06169af08d299a298f12daf0fc61c Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 18 Mar 2024 14:46:07 -0500 Subject: [PATCH] Cleanup test (#353) --- .../src/js/src/elements/ElementUtils.test.tsx | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/plugins/ui/src/js/src/elements/ElementUtils.test.tsx b/plugins/ui/src/js/src/elements/ElementUtils.test.tsx index 165432061..45fb673ce 100644 --- a/plugins/ui/src/js/src/elements/ElementUtils.test.tsx +++ b/plugins/ui/src/js/src/elements/ElementUtils.test.tsx @@ -97,31 +97,27 @@ describe('wrapElementChildren', () => { ])( 'should wrap primitive item element children in Text elements: %s, %s', (children, expectedChildren) => { - const given = - textValue == null - ? { - [ELEMENT_KEY]: ITEM_ELEMENT_NAME, - props: { children }, - } - : { - [ELEMENT_KEY]: ITEM_ELEMENT_NAME, - props: { textValue, children }, - }; + const givenProps = + textValue == null ? { children } : { textValue, children }; - const actual = wrapElementChildren(given); - - const fallbackTextValue = Array.isArray(children) - ? undefined - : String(children); + const expectedTextValue = + textValue == null && isPrimitive(children) + ? String(children) + : textValue; const expected = { [ELEMENT_KEY]: ITEM_ELEMENT_NAME, props: { - textValue: textValue ?? fallbackTextValue, + textValue: expectedTextValue, children: expectedChildren, }, }; + const actual = wrapElementChildren({ + [ELEMENT_KEY]: ITEM_ELEMENT_NAME, + props: givenProps, + }); + expect(actual).toEqual(expected); } );