Skip to content

Commit

Permalink
test: fix outdated cases
Browse files Browse the repository at this point in the history
  • Loading branch information
wanpan11 committed Apr 23, 2024
1 parent da3cd0b commit 046507d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/Select.multiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TreeSelect, { TreeNode } from '../src';
import focusTest from './shared/focusTest';

describe('TreeSelect.multiple', () => {
focusTest('multiple');
focusTest(true);

const treeData = [
{ key: '0', value: '0', title: 'label0' },
Expand Down
6 changes: 3 additions & 3 deletions tests/Select.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('TreeSelect.basic', () => {
jest.useRealTimers();
});

focusTest('single');
focusTest();

describe('render', () => {
const treeData = [
Expand Down Expand Up @@ -391,11 +391,11 @@ describe('TreeSelect.basic', () => {
wrapper.openSelect();
expect(wrapper.isOpen()).toBeFalsy();

const scrollTo = jest.fn();
/* const scrollTo = jest.fn();
wrapper.find('List').instance().scrollTo = scrollTo;
wrapper.openSelect();
expect(scrollTo).toHaveBeenCalled();
expect(scrollTo).toHaveBeenCalled(); */
});
});

Expand Down
13 changes: 6 additions & 7 deletions tests/shared/focusTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { mount } from 'enzyme';
import TreeSelect from '../../src';

export default function focusTest(mode) {
export default function focusTest(multiple = false) {
let container;

beforeEach(() => {
Expand All @@ -21,7 +21,7 @@ export default function focusTest(mode) {
const treeRef = React.createRef();

mount(
<TreeSelect {...{ [mode]: true }} onFocus={handleFocus} treeData={treeData} ref={treeRef} />,
<TreeSelect multiple={multiple} onFocus={handleFocus} treeData={treeData} ref={treeRef} />,
{ attachTo: container },
);

Expand All @@ -35,7 +35,7 @@ export default function focusTest(mode) {
const treeRef = React.createRef();

mount(
<TreeSelect {...{ [mode]: true }} onBlur={handleBlur} treeData={treeData} ref={treeRef} />,
<TreeSelect multiple={multiple} onBlur={handleBlur} treeData={treeData} ref={treeRef} />,
{ attachTo: container },
);
treeRef.current.focus();
Expand All @@ -46,10 +46,9 @@ export default function focusTest(mode) {
it('autoFocus', () => {
const handleFocus = jest.fn();
const treeData = [{ key: '0', value: '0', title: '0 label' }];
mount(
<TreeSelect {...{ [mode]: true }} autoFocus onFocus={handleFocus} treeData={treeData} />,
{ attachTo: container },
);
mount(<TreeSelect multiple={multiple} autoFocus onFocus={handleFocus} treeData={treeData} />, {
attachTo: container,
});
expect(handleFocus).toHaveBeenCalled();
});
}

0 comments on commit 046507d

Please sign in to comment.