Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(smartSort): add widget #3009

Merged
merged 18 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,36 @@ describe('SmartSort', () => {
/>
);

expect(tree.toJSON()).toMatchSnapshot();
expect(tree.root.props.className.includes('MyCustomSmartSort')).toBe(true);
});

it('forward isSmartSorted to props components', () => {
const mockTextComponent = jest.fn(() => null);

const mockButtonTextComponent = jest.fn(() => null);

const tree = renderer.create(
<SmartSort
buttonTextComponent={ButtonTextComponent}
buttonTextComponent={mockTextComponent}
isVirtualReplica={true}
isSmartSorted={true}
refine={() => {}}
textComponent={TextComponent}
textComponent={mockButtonTextComponent}
/>
);

expect(mockTextComponent).toHaveBeenCalledWith(
{
isSmartSorted: true,
},
{}
);
expect(mockButtonTextComponent).toHaveBeenCalledWith(
{
isSmartSorted: true,
},
{}
);
expect(tree.toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SmartSort accepts a custom className 1`] = `
<div
className="ais-SmartSort MyCustomSmartSort"
>
<div
className="ais-SmartSort-text"
>
<div>
Currently showing all results
</div>
</div>
<button
className="ais-SmartSort-button"
onClick={[Function]}
>
<div>
See relevant results
</div>
</button>
</div>
`;

exports[`SmartSort forward isSmartSorted to props components 1`] = `
<div
className="ais-SmartSort"
>
<div
className="ais-SmartSort-text"
>
<div>
We removed some search results to show you the most relevant ones
</div>
</div>
/>
<button
className="ais-SmartSort-button"
onClick={[Function]}
>
<div>
See all results
</div>
</button>
/>
</div>
`;