@@ -4,7 +4,7 @@ import type { CascaderRef, BaseOptionType, CascaderProps } from '../src';
44import Cascader from '../src' ;
55import { addressOptions , addressOptionsForUneven , optionsForActiveMenuItems } from './demoOptions' ;
66import { mount } from './enzyme' ;
7- import { toRawValues } from '../src/utils/commonUtil' ;
7+ import * as commonUtil from '../src/utils/commonUtil' ;
88import { act , fireEvent , render } from '@testing-library/react' ;
99import KeyCode from '@rc-component/util/lib/KeyCode' ;
1010import { expectOpen , selectOption } from './util' ;
@@ -1075,7 +1075,7 @@ describe('Cascader.Basic', () => {
10751075 } ) ;
10761076 const items = wrapper . container . querySelectorAll ( '.rc-cascader-menu-item' ) ;
10771077 fireEvent . mouseEnter ( items [ 9 ] ) ;
1078- expect ( mockScrollTo ) . toHaveBeenCalledTimes ( 0 ) ;
1078+ expect ( mockScrollTo ) . toHaveBeenCalledTimes ( 1 ) ;
10791079
10801080 spyElement . mockRestore ( ) ;
10811081 } ) ;
@@ -1094,18 +1094,12 @@ describe('Cascader.Basic', () => {
10941094 const input = container . querySelector ( 'input' ) ! ;
10951095 fireEvent . focus ( input ) ;
10961096
1097+ const spy = jest . spyOn ( commonUtil , 'scrollIntoParentView' ) ;
10971098 fireEvent . keyDown ( input , { key : 'ArrowDown' , keyCode : KeyCode . DOWN } ) ;
10981099
10991100 const targetElement = container . querySelector ( '.rc-cascader-menu-item-active' ) ! ;
1100-
1101- const scrollSpy = jest . spyOn ( targetElement , 'scrollIntoView' ) . mockImplementation ( ( ) => null ) ;
1102-
1103- expect ( scrollSpy ) . toHaveBeenCalledWith ( {
1104- block : 'nearest' ,
1105- inline : 'nearest' ,
1106- } ) ;
1107-
1108- scrollSpy . mockReset ( ) ;
1101+ expect ( spy ) . toHaveBeenCalledWith ( targetElement ) ;
1102+ spy . mockRestore ( ) ;
11091103 } ) ;
11101104 } ) ;
11111105
@@ -1149,7 +1143,7 @@ describe('Cascader.Basic', () => {
11491143 errorSpy . mockReset ( ) ;
11501144 } ) ;
11511145 it ( 'toRawValues undefined' , ( ) => {
1152- expect ( toRawValues ( ) ) . toEqual ( [ ] ) ;
1146+ expect ( commonUtil . toRawValues ( ) ) . toEqual ( [ ] ) ;
11531147 } ) ;
11541148
11551149 it ( 'nativeElement' , ( ) => {
0 commit comments