Skip to content

Commit c5613ca

Browse files
authored
Merge 4c33859 into 510e196
2 parents 510e196 + 4c33859 commit c5613ca

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
},
4747
"dependencies": {
4848
"@babel/runtime": "^7.10.1",
49+
"@rc-component/trigger": "^1.5.0",
4950
"classnames": "^2.2.6",
5051
"rc-input": "^0.2.2",
5152
"rc-menu": "~9.8.0",
5253
"rc-textarea": "^1.0.0",
53-
"rc-trigger": "^5.0.4",
5454
"rc-util": "^5.22.5"
5555
},
5656
"devDependencies": {

src/KeywordTrigger.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import Trigger from 'rc-trigger';
1+
import Trigger from '@rc-component/trigger';
2+
import type { FC } from 'react';
23
import * as React from 'react';
3-
import { FC, useMemo } from 'react';
4+
import { useMemo } from 'react';
45
import DropdownMenu from './DropdownMenu';
56
import type { DataDrivenOptionProps, Direction, Placement } from './Mentions';
67

tests/FullProcess.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { fireEvent, render } from '@testing-library/react';
12
import KeyCode from 'rc-util/lib/KeyCode';
23
import React from 'react';
3-
import { fireEvent, render } from '@testing-library/react';
4-
import Mentions from '../src';
54
import type { MentionsProps } from '../src';
5+
import Mentions from '../src';
66
import { expectMatchOptions, expectMeasuring, simulateInput } from './util';
77

88
describe('Full Process', () => {
@@ -145,7 +145,7 @@ describe('Full Process', () => {
145145
});
146146

147147
it('should support same value', () => {
148-
const { container } = render(
148+
const { container, baseElement } = render(
149149
<Mentions
150150
options={[
151151
{
@@ -170,7 +170,7 @@ describe('Full Process', () => {
170170

171171
simulateInput(container, '@');
172172
expect(
173-
container.querySelectorAll('li.rc-mentions-dropdown-menu-item-active'),
173+
baseElement.querySelectorAll('li.rc-mentions-dropdown-menu-item-active'),
174174
).toHaveLength(2);
175175
});
176176

tests/Mentions.spec.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Mentions', () => {
5656

5757
it('not lose focus if click on dropdown', () => {
5858
const onBlur = jest.fn();
59-
const { container } = renderMentions({
59+
const { container, baseElement } = renderMentions({
6060
autoFocus: true,
6161
defaultValue: '@',
6262
onBlur,
@@ -69,11 +69,11 @@ describe('Mentions', () => {
6969
});
7070

7171
fireEvent.focus(
72-
container.querySelector('li.rc-mentions-dropdown-menu-item'),
72+
baseElement.querySelector('li.rc-mentions-dropdown-menu-item'),
7373
);
7474
fireEvent.blur(container.querySelector('textarea'));
7575
fireEvent.click(
76-
container.querySelector('li.rc-mentions-dropdown-menu-item'),
76+
baseElement.querySelector('li.rc-mentions-dropdown-menu-item'),
7777
);
7878
fireEvent.focus(container.querySelector('textarea'));
7979

@@ -177,13 +177,15 @@ describe('Mentions', () => {
177177
});
178178

179179
it('do not lose label', () => {
180-
const { container } = renderOptionsMentions();
180+
const { container, baseElement } = renderOptionsMentions();
181181
simulateInput(container, '@');
182182
fireEvent.mouseEnter(
183-
container.querySelector('li.rc-mentions-dropdown-menu-item:last-child'),
183+
baseElement.querySelector(
184+
'li.rc-mentions-dropdown-menu-item:last-child',
185+
),
184186
);
185187
expect(
186-
container.querySelector('.rc-mentions-dropdown-menu-item-active')
188+
baseElement.querySelector('.rc-mentions-dropdown-menu-item-active')
187189
.textContent,
188190
).toBe('Cat');
189191
});
@@ -224,33 +226,37 @@ describe('Mentions', () => {
224226

225227
describe('accessibility', () => {
226228
it('hover', () => {
227-
const { container } = renderMentions();
229+
const { container, baseElement } = renderMentions();
228230
simulateInput(container, '@');
229231
fireEvent.mouseEnter(
230-
container.querySelector('li.rc-mentions-dropdown-menu-item:last-child'),
232+
baseElement.querySelector(
233+
'li.rc-mentions-dropdown-menu-item:last-child',
234+
),
231235
);
232236
expect(
233-
container.querySelector('.rc-mentions-dropdown-menu-item-active')
237+
baseElement.querySelector('.rc-mentions-dropdown-menu-item-active')
234238
.textContent,
235239
).toBe('Cat');
236240
});
237241
});
238242

239243
it('dropdownClassName should work', () => {
240-
const { container } = renderMentions({ dropdownClassName: 'my-dropdown' });
244+
const { container, baseElement } = renderMentions({
245+
dropdownClassName: 'my-dropdown',
246+
});
241247
simulateInput(container, '@');
242248
expect(
243-
container.querySelector('.my-dropdown.rc-mentions-dropdown'),
249+
baseElement.querySelector('.my-dropdown.rc-mentions-dropdown'),
244250
).toBeTruthy();
245251
});
246252

247253
it('should support direction', () => {
248-
const { container } = renderMentions({ direction: 'rtl' });
254+
const { container, baseElement } = renderMentions({ direction: 'rtl' });
249255
simulateInput(container, '@');
250256
act(() => {
251257
jest.runAllTimers();
252258
});
253-
expect(container.querySelector('.rc-mentions-dropdown')).toBeTruthy();
259+
expect(baseElement.querySelector('.rc-mentions-dropdown')).toBeTruthy();
254260
});
255261

256262
it('should support textarea in ref', () => {

tests/__mocks__/rc-trigger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import Trigger from 'rc-trigger/lib/mock';
1+
import Trigger from '@rc-component/trigger/lib/mock';
22

33
export default Trigger;

0 commit comments

Comments
 (0)