Skip to content

Commit

Permalink
Cleanup test (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Mar 18, 2024
1 parent ff4cd5f commit 8819311
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions plugins/ui/src/js/src/elements/ElementUtils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
Expand Down

0 comments on commit 8819311

Please sign in to comment.