Skip to content

Commit c03a03e

Browse files
committed
test: batch update
1 parent db75428 commit c03a03e

File tree

6 files changed

+35
-41
lines changed

6 files changed

+35
-41
lines changed

tests/Multiple.test.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,14 @@ describe('Select.Multiple', () => {
512512
const { container } = render(
513513
<Select mode="multiple" options={[{ value: 'title' }]} value={['title']} />,
514514
);
515-
expect(container.querySelector('.rc-select-selection-item').getAttribute('title')).toBe(
516-
'title',
517-
);
515+
expect(container.querySelector('.rc-select-item').getAttribute('title')).toBe('title');
518516
});
519517

520518
it('should not render title defaultly when label is ReactNode', () => {
521519
const { container } = render(
522520
<Select mode="multiple" options={[{ value: '1', label: <div>label</div> }]} value={['1']} />,
523521
);
524-
expect(container.querySelector('.rc-select-selection-item').getAttribute('title')).toBeFalsy();
522+
expect(container.querySelector('.rc-select-item').getAttribute('title')).toBeFalsy();
525523
});
526524

527525
it('disabled should not show remove icon', () => {
@@ -533,7 +531,7 @@ describe('Select.Multiple', () => {
533531
</Select>,
534532
);
535533

536-
expect(container.querySelector('.rc-select-selection-item-remove')).toBeFalsy();
534+
expect(container.querySelector('.rc-select-item-remove')).toBeFalsy();
537535
});
538536

539537
it('do not crash if value not in options when removing option', () => {
@@ -573,8 +571,8 @@ describe('Select.Multiple', () => {
573571
</Select>,
574572
);
575573

576-
expect(wrapper1.container.querySelector('.rc-select-selection-item')).toBeFalsy();
577-
expect(wrapper2.container.querySelector('.rc-select-selection-item')).toBeFalsy();
574+
expect(wrapper1.container.querySelector('.rc-select-item')).toBeFalsy();
575+
expect(wrapper2.container.querySelector('.rc-select-item')).toBeFalsy();
578576
});
579577

580578
describe('optionLabelProp', () => {

tests/Select.test.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,10 +1830,10 @@ describe('Select.Basic', () => {
18301830
[undefined].forEach((value) => {
18311831
it(`to ${value}`, () => {
18321832
const { container, rerender } = render(<Select value="light" />);
1833-
expect(container.querySelector('.rc-select-selection-item').textContent).toEqual('light');
1833+
expect(container.querySelector('.rc-select-item').textContent).toEqual('light');
18341834

18351835
rerender(<Select value={value} />);
1836-
expect(container.querySelector('.rc-select-selection-item')).toBeFalsy();
1836+
expect(container.querySelector('.rc-select-item')).toBeFalsy();
18371837
});
18381838
});
18391839
});
@@ -1936,7 +1936,7 @@ describe('Select.Basic', () => {
19361936
toggleOpen(container);
19371937
selectItem(container, index);
19381938
expect(onChange).toHaveBeenCalledWith(value, expect.anything());
1939-
expect(container.querySelector('.rc-select-selection-item').textContent).toEqual(showValue);
1939+
expect(container.querySelector('.rc-select-item').textContent).toEqual(showValue);
19401940
});
19411941

19421942
expect(errorSpy).toHaveBeenCalledWith(warningMessage);
@@ -2204,8 +2204,8 @@ describe('Select.Basic', () => {
22042204
<Select value="b" options={[{ label: 'bamboo', title: 'TitleBamboo', value: 'b' }]} />,
22052205
);
22062206

2207-
// expect(container.find('.rc-select-selection-item').prop('title')).toEqual('TitleBamboo');
2208-
expect(container.querySelector('.rc-select-selection-item').getAttribute('title')).toEqual(
2207+
// expect(container.find('.rc-select-item').prop('title')).toEqual('TitleBamboo');
2208+
expect(container.querySelector('.rc-select-item').getAttribute('title')).toEqual(
22092209
'TitleBamboo',
22102210
);
22112211
});
@@ -2224,15 +2224,15 @@ describe('Select.Basic', () => {
22242224
/>,
22252225
);
22262226

2227-
expect(
2228-
container.querySelectorAll('span.rc-select-selection-item')[0].getAttribute('title'),
2229-
).toEqual('TitleBamboo');
2230-
expect(
2231-
container.querySelectorAll('span.rc-select-selection-item')[1].getAttribute('title'),
2232-
).toEqual('little');
2233-
expect(
2234-
container.querySelectorAll('span.rc-select-selection-item')[2].getAttribute('title'),
2235-
).toEqual('+ 1 ...');
2227+
expect(container.querySelectorAll('span.rc-select-item')[0].getAttribute('title')).toEqual(
2228+
'TitleBamboo',
2229+
);
2230+
expect(container.querySelectorAll('span.rc-select-item')[1].getAttribute('title')).toEqual(
2231+
'little',
2232+
);
2233+
expect(container.querySelectorAll('span.rc-select-item')[2].getAttribute('title')).toEqual(
2234+
'+ 1 ...',
2235+
);
22362236
});
22372237
});
22382238

@@ -2261,19 +2261,15 @@ describe('Select.Basic', () => {
22612261
it('should support title', () => {
22622262
const { container: container1 } = render(<Select defaultValue="lucy" options={[]} />);
22632263
expect(container1.querySelector('.rc-select').getAttribute('title')).toBeFalsy();
2264-
expect(container1.querySelector('.rc-select-selection-item').getAttribute('title')).toBe(
2265-
'lucy',
2266-
);
2264+
expect(container1.querySelector('.rc-select-item').getAttribute('title')).toBe('lucy');
22672265
const { container: container2 } = render(<Select defaultValue="lucy" options={[]} title="" />);
22682266
expect(container2.querySelector('.rc-select').getAttribute('title')).toBeFalsy();
2269-
expect(container2.querySelector('.rc-select-selection-item').getAttribute('title')).toBe('');
2267+
expect(container2.querySelector('.rc-select-item').getAttribute('title')).toBe('');
22702268
const { container: container3 } = render(
22712269
<Select defaultValue="lucy" options={[]} title="title" />,
22722270
);
22732271
expect(container3.querySelector('.rc-select').getAttribute('title')).toBe('title');
2274-
expect(container3.querySelector('.rc-select-selection-item').getAttribute('title')).toBe(
2275-
'title',
2276-
);
2272+
expect(container3.querySelector('.rc-select-item').getAttribute('title')).toBe('title');
22772273
});
22782274

22792275
it('scrollbar should be left position with rtl direction', () => {

tests/placeholder.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ describe('Select placeholder', () => {
2626
<Select value={null} placeholder="bamboo" options={[{ value: null, label: 'light' }]} />,
2727
);
2828
expect(container.querySelector('.rc-select-placeholder')).toBeFalsy();
29-
expect(container.querySelector('.rc-select-selection-item').textContent).toBe('light');
29+
expect(container.querySelector('.rc-select-item').textContent).toBe('light');
3030
toggleOpen(container);
31-
expect(container.querySelector('.rc-select-selection-item').textContent).toBe('light');
31+
expect(container.querySelector('.rc-select-item').textContent).toBe('light');
3232
});
3333

3434
it('should hide placeholder if force closed and showSearch with searchValue', () => {

tests/shared/maxTagRenderTest.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function maxTagTextLengthTest(mode: any) {
2626
</Select>,
2727
);
2828

29-
expect(container.querySelectorAll('.rc-select-selection-item')).toHaveLength(3);
29+
expect(container.querySelectorAll('.rc-select-item')).toHaveLength(3);
3030
});
3131

3232
it('truncates tags by maxTagCount while maxTagCount is 0', () => {
@@ -38,7 +38,7 @@ export default function maxTagTextLengthTest(mode: any) {
3838
</Select>,
3939
);
4040

41-
expect(container.querySelectorAll('.rc-select-selection-item')).toHaveLength(1);
41+
expect(container.querySelectorAll('.rc-select-item')).toHaveLength(1);
4242
expect(findSelection(container).textContent).toEqual('+ 3 ...');
4343
});
4444

tests/shared/removeSelectedTest.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function removeSelectedTest(mode: any) {
4242
</Select>,
4343
);
4444

45-
expect(container.querySelector('.rc-select-selection-item-remove')).toBeFalsy();
45+
expect(container.querySelector('.rc-select-item-remove')).toBeFalsy();
4646
});
4747

4848
it('wrap value when labelInValue', () => {

tests/utils/common.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ export function selectItem(wrapper: any, index: number = 0) {
3434

3535
export function findSelection(wrapper: any, index: number = 0) {
3636
if (wrapper instanceof HTMLElement) {
37-
const itemNode = wrapper.querySelectorAll('.rc-select-selection-item')[index];
38-
const contentNode = itemNode.querySelector('.rc-select-selection-item-content');
37+
const itemNode = wrapper.querySelectorAll('.rc-select-item')[index];
38+
const contentNode = itemNode.querySelector('.rc-select-item-content');
3939

4040
if (contentNode) {
4141
return contentNode;
4242
}
4343

4444
return itemNode;
4545
} else {
46-
const itemNode = wrapper.find('.rc-select-selection-item').at(index);
47-
const contentNode = itemNode.find('.rc-select-selection-item-content');
46+
const itemNode = wrapper.find('.rc-select-item').at(index);
47+
const contentNode = itemNode.find('.rc-select-item-content');
4848

4949
if (contentNode.length) {
5050
return contentNode;
@@ -58,17 +58,17 @@ export function removeSelection(wrapper: any, index: number = 0) {
5858
const preventDefault = jest.fn();
5959

6060
if (wrapper instanceof HTMLElement) {
61-
const ele = wrapper.querySelectorAll('.rc-select-selection-item-remove')[index];
61+
const ele = wrapper.querySelectorAll('.rc-select-item-remove')[index];
6262
const mouseDownEvent = createEvent.mouseDown(ele);
6363
mouseDownEvent.preventDefault = preventDefault;
6464

6565
fireEvent(ele, mouseDownEvent);
66-
fireEvent.click(wrapper.querySelectorAll('.rc-select-selection-item-remove')[index]);
66+
fireEvent.click(wrapper.querySelectorAll('.rc-select-item-remove')[index]);
6767
} else {
6868
wrapper
69-
.find('.rc-select-selection-item')
69+
.find('.rc-select-item')
7070
.at(index)
71-
.find('.rc-select-selection-item-remove')
71+
.find('.rc-select-item-remove')
7272
.last()
7373
.simulate('mousedown', { preventDefault })
7474
.simulate('click');

0 commit comments

Comments
 (0)