Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/testing/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ export interface AssertionResult {
): AssertionResult;
insertAfter<T extends WidgetFactory>(target: Wrapped<T>, children: TemplateChildren): AssertionResult;
insertSiblings<T extends WidgetBaseInterface>(
target: T,
target: Wrapped<Constructor<T>>,
children: TemplateChildren,
type?: 'before' | 'after'
): AssertionResult;
insertSiblings<T extends WidgetFactory>(
target: Wrapped<T>,
children: TemplateChildren,
type?: 'before' | 'after'
): AssertionResult;
Expand Down
14 changes: 12 additions & 2 deletions tests/testing/unit/assertion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => [<div>after</div>]);
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(() => <MyWidget toggleProperty={true} />);
r.expect(tsxAssertion.setProperty(WrappedListItem, 'foo', 'b'));
Expand Down