From 52b81ad79fcfc93c516489c1894b4a1892399da9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?=
<7971419+crazyair@users.noreply.github.com>
Date: Mon, 2 Sep 2024 18:07:04 +0800
Subject: [PATCH] feat: test (#531)
* feat: test
* feat: test
---
tests/search.spec.tsx | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/tests/search.spec.tsx b/tests/search.spec.tsx
index 8b13be94..12c7b394 100644
--- a/tests/search.spec.tsx
+++ b/tests/search.spec.tsx
@@ -193,7 +193,7 @@ describe('Cascader.Search', () => {
errorSpy.mockRestore();
});
- it('onChange should be triggered when click option with multiple', () => {
+ it('onChange should be triggered when click option with changeOnSelect + multiple', () => {
const onChange = jest.fn();
const wrapper = mount(
,
@@ -212,6 +212,23 @@ describe('Cascader.Search', () => {
);
});
+ it('onChange should be triggered when click option with multiple', () => {
+ const onChange = jest.fn();
+ const wrapper = mount();
+ doSearch(wrapper, 'toy');
+ wrapper.find('.rc-cascader-menu-item').first().simulate('click');
+ wrapper.find('.rc-cascader-menu-item').first().simulate('mousedown');
+ expect(onChange).toHaveBeenCalledWith([['bamboo', 'little', 'fish']], expect.anything());
+
+ doSearch(wrapper, 'light');
+ wrapper.find('.rc-cascader-menu-item').first().simulate('click');
+ wrapper.find('.rc-cascader-menu-item').first().simulate('mousedown');
+ expect(onChange).toHaveBeenCalledWith(
+ [['bamboo', 'little', 'fish'], ['light']],
+ expect.anything(),
+ );
+ });
+
it('should not crash when exist options with same value on different levels', () => {
const wrapper = mount();