From 2bcfa3aa119cb60ef26bfa876020ad1b640b7af7 Mon Sep 17 00:00:00 2001 From: Sam Menza Date: Fri, 15 Jan 2021 15:29:48 -0500 Subject: [PATCH 1/2] Added overload insertSiblings definition --- src/testing/renderer.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/testing/renderer.ts b/src/testing/renderer.ts index dc0116754..17be3be23 100644 --- a/src/testing/renderer.ts +++ b/src/testing/renderer.ts @@ -172,7 +172,12 @@ export interface AssertionResult { ): AssertionResult; insertAfter(target: Wrapped, children: TemplateChildren): AssertionResult; insertSiblings( - target: T, + target: Wrapped>, + children: TemplateChildren, + type?: 'before' | 'after' + ): AssertionResult; + insertSiblings( + target: Wrapped, children: TemplateChildren, type?: 'before' | 'after' ): AssertionResult; From 44e0ce9f53b8dff07b27b352e65b4016933703a0 Mon Sep 17 00:00:00 2001 From: Sam Menza Date: Fri, 15 Jan 2021 15:35:15 -0500 Subject: [PATCH 2/2] Added unit tests for inserSiblings --- tests/testing/unit/assertion.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/testing/unit/assertion.tsx b/tests/testing/unit/assertion.tsx index 192f9c178..438a14466 100644 --- a/tests/testing/unit/assertion.tsx +++ b/tests/testing/unit/assertion.tsx @@ -317,22 +317,32 @@ describe('new/assertion', () => { r.expect(baseAssertion.append(WrappedHeader, () => ['append'])); }); - it('can set children after with insert', () => { + it('can set children after with insert after', () => { const r = renderer(() => w(MyWidget, { after: true })); r.expect(baseAssertion.insertAfter(WrappedList, () => [v('span', ['after'])])); }); + it('can set children after with insert sibling', () => { + const r = renderer(() => w(MyWidget, { after: true })); + r.expect(baseAssertion.insertSiblings(WrappedList, () => [v('span', ['after'])], 'after')); + }); + it('can insert after a node in the root', () => { const insertionAssertion = baseMultiRootAssertion.insertAfter(WrappedFirst, () => [
after
]); const r = renderer(() => w(MultiRootWidget, { after: true })); r.expect(insertionAssertion); }); - it('can set children before with insert', () => { + it('can set children before with insert before', () => { const r = renderer(() => w(MyWidget, { before: true })); r.expect(baseAssertion.insertBefore(WrappedList, () => [v('span', ['before'])])); }); + it('can set children before with insert sibling ', () => { + const r = renderer(() => w(MyWidget, { before: true })); + r.expect(baseAssertion.insertSiblings(WrappedList, () => [v('span', ['before'])], 'before')); + }); + it('can be used with tsx', () => { const r = renderer(() => ); r.expect(tsxAssertion.setProperty(WrappedListItem, 'foo', 'b'));