Skip to content

Commit b1bbc34

Browse files
fix: update data-testid to new format
1 parent d962836 commit b1bbc34

File tree

3 files changed

+54
-54
lines changed

3 files changed

+54
-54
lines changed

docs/main.484528c7.iframe.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Combobox/Combobox.spec.js

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,43 @@ describe('<Combobox />', () => {
2222

2323
it('should render with empty options array', () => {
2424
const combobox = render(<Combobox options={[]} />);
25-
combobox.getByTestId('combobox-input');
25+
combobox.getByTestId('react-gears-combobox-input');
2626
});
2727

2828
it('should show options when focused', () => {
2929
const combobox = render(<Combobox options={OPTIONS} />);
30-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
30+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
3131

32-
const input = combobox.getByTestId('combobox-input');
32+
const input = combobox.getByTestId('react-gears-combobox-input');
3333
fireEvent.focus(input);
3434

35-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
35+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
3636
});
3737

3838
it('should pass inputClassName to Input', () => {
3939
const innerClassName = 'js-no-autofocus';
4040
const combobox = render(<Combobox options={OPTIONS} inputClassName={innerClassName} />);
4141

42-
assert(combobox.getByTestId('combobox-input').classList.contains(innerClassName));
42+
assert(combobox.getByTestId('react-gears-combobox-input').classList.contains(innerClassName));
4343
});
4444

4545
it('should have "search" as default Input type', () => {
4646
const combobox = render(<Combobox options={[]} />);
47-
const input = combobox.getByTestId('combobox-input');
47+
const input = combobox.getByTestId('react-gears-combobox-input');
4848

4949
assert.strictEqual(input.type, 'search');
5050
});
5151

5252
it('should pass type to Input', () => {
5353
const combobox = render(<Combobox options={[]} type="text" />);
54-
const input = combobox.getByTestId('combobox-input');
54+
const input = combobox.getByTestId('react-gears-combobox-input');
5555

5656
assert.strictEqual(input.type, 'text');
5757
});
5858

5959
it('should show all options when there is a selected option', () => {
6060
const combobox = render(<Combobox options={OPTIONS} value={OPTIONS[0]} />);
61-
const input = combobox.getByTestId('combobox-input');
61+
const input = combobox.getByTestId('react-gears-combobox-input');
6262
fireEvent.focus(input);
6363

6464
OPTIONS.forEach((o) => {
@@ -70,7 +70,7 @@ describe('<Combobox />', () => {
7070
const mockOnChange = sinon.spy();
7171
const combobox = render(<Combobox options={OPTIONS} onChange={mockOnChange} />);
7272

73-
const input = combobox.getByTestId('combobox-input');
73+
const input = combobox.getByTestId('react-gears-combobox-input');
7474
fireEvent.focus(input);
7575

7676
const option = combobox.getByText('D-O');
@@ -83,43 +83,43 @@ describe('<Combobox />', () => {
8383
it('should close menu on blur', () => {
8484
const combobox = render(<Combobox options={OPTIONS} />);
8585

86-
const input = combobox.getByTestId('combobox-input');
86+
const input = combobox.getByTestId('react-gears-combobox-input');
8787
fireEvent.focus(input);
8888

89-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
89+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
9090

9191
fireEvent.blur(input);
9292

93-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
93+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
9494
});
9595

9696
it('should not close menu when menu container is focused', () => {
9797
const combobox = render(<Combobox options={OPTIONS} />);
98-
const input = combobox.getByTestId('combobox-input');
98+
const input = combobox.getByTestId('react-gears-combobox-input');
9999
fireEvent.focus(input);
100-
const dropdown = combobox.getByTestId('combobox-dropdown');
101-
const menu = combobox.getByTestId('combobox-menu');
100+
const dropdown = combobox.getByTestId('react-gears-combobox-dropdown');
101+
const menu = combobox.getByTestId('react-gears-combobox-menu');
102102
fireEvent.blur(dropdown, { relatedTarget: menu });
103103

104-
expect(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden')).toEqual('false');
104+
expect(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden')).toEqual('false');
105105
});
106106

107107
it('should close menu on blur of caret button', () => {
108108
const combobox = render(<Combobox options={OPTIONS} />);
109109

110-
const caret = combobox.getByTestId('combobox-caret');
110+
const caret = combobox.getByTestId('react-gears-combobox-caret');
111111
fireEvent.mouseDown(caret);
112112

113-
assert.strictEqual(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
113+
assert.strictEqual(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
114114

115115
fireEvent.blur(caret);
116116

117-
assert.strictEqual(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
117+
assert.strictEqual(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
118118
});
119119

120120
it('should blur input on close', () => {
121121
const combobox = render(<Combobox options={OPTIONS} />);
122-
const input = combobox.getByTestId('combobox-input');
122+
const input = combobox.getByTestId('react-gears-combobox-input');
123123
input.focus();
124124

125125
let option = combobox.getByText('D-O');
@@ -141,7 +141,7 @@ describe('<Combobox />', () => {
141141
it('should navigate options by up/down keys', () => {
142142
const combobox = render(<Combobox options={OPTIONS} />);
143143

144-
const input = combobox.getByTestId('combobox-input');
144+
const input = combobox.getByTestId('react-gears-combobox-input');
145145
fireEvent.focus(input);
146146

147147
assert(combobox.getByText('R2-D2').classList.contains('active'));
@@ -168,7 +168,7 @@ describe('<Combobox />', () => {
168168
/>
169169
);
170170

171-
const input = combobox.getByTestId('combobox-input');
171+
const input = combobox.getByTestId('react-gears-combobox-input');
172172
fireEvent.click(input);
173173

174174
assert.strictEqual(input.value, 'bar');
@@ -178,15 +178,15 @@ describe('<Combobox />', () => {
178178
const mockOnChange = sinon.spy();
179179
const combobox = render(<Combobox options={OPTIONS} onChange={mockOnChange} />);
180180

181-
const input = combobox.getByTestId('combobox-input');
181+
const input = combobox.getByTestId('react-gears-combobox-input');
182182
fireEvent.focus(input);
183183
fireEvent.keyDown(input, { key: 'ArrowDown', code: 40 });
184184

185185
assert(combobox.getByText('BB8').classList.contains('active'));
186186

187187
fireEvent.keyDown(input, { key: 'Enter', code: 13 });
188188

189-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
189+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
190190
sinon.assert.called(mockOnChange);
191191
sinon.assert.calledWith(mockOnChange, OPTIONS[1].value);
192192
});
@@ -197,7 +197,7 @@ describe('<Combobox />', () => {
197197
value = v;
198198
};
199199
let combobox = render(<Combobox options={OPTIONS} onChange={mockOnChange} value={value} />);
200-
let input = combobox.getByTestId('combobox-input');
200+
let input = combobox.getByTestId('react-gears-combobox-input');
201201
fireEvent.focus(input);
202202

203203
const option = combobox.getByText('D-O');
@@ -207,7 +207,7 @@ describe('<Combobox />', () => {
207207

208208
cleanup();
209209
combobox = render(<Combobox options={OPTIONS} onChange={mockOnChange} value={value} />);
210-
input = combobox.getByTestId('combobox-input');
210+
input = combobox.getByTestId('react-gears-combobox-input');
211211

212212
fireEvent.mouseDown(input);
213213
fireEvent.keyDown(input, { key: 'Backspace', code: 8 });
@@ -218,55 +218,55 @@ describe('<Combobox />', () => {
218218
it('should open options with down key', () => {
219219
const combobox = render(<Combobox options={OPTIONS} />);
220220

221-
const input = combobox.getByTestId('combobox-input');
221+
const input = combobox.getByTestId('react-gears-combobox-input');
222222
fireEvent.focus(input);
223223

224-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
224+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
225225

226-
const caret = combobox.getByTestId('combobox-caret');
226+
const caret = combobox.getByTestId('react-gears-combobox-caret');
227227
fireEvent.mouseDown(caret);
228228

229-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
229+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
230230

231231
fireEvent.keyDown(input, { key: 'ArrowDown', code: 40 });
232232

233-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
233+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
234234
});
235235

236236
it('should open options if input is clicked', async () => {
237237
const combobox = render(<Combobox options={OPTIONS} value={3} />);
238238

239-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
239+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
240240

241-
const input = combobox.getByTestId('combobox-input');
241+
const input = combobox.getByTestId('react-gears-combobox-input');
242242
fireEvent.mouseDown(input);
243243

244-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
244+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
245245
});
246246

247247
it('should open/close options with dropdown toggle', () => {
248248
const combobox = render(<Combobox options={OPTIONS} />);
249249

250-
const input = combobox.getByTestId('combobox-input');
250+
const input = combobox.getByTestId('react-gears-combobox-input');
251251
fireEvent.focus(input);
252252

253-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
253+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
254254

255-
const caret = combobox.getByTestId('combobox-caret');
255+
const caret = combobox.getByTestId('react-gears-combobox-caret');
256256
fireEvent.mouseDown(caret);
257257

258-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'true');
258+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'true');
259259

260260
fireEvent.mouseDown(caret);
261261

262-
assert.equal(combobox.getByTestId('combobox-menu').getAttribute('aria-hidden'), 'false');
262+
assert.equal(combobox.getByTestId('react-gears-combobox-menu').getAttribute('aria-hidden'), 'false');
263263
});
264264

265265
describe('default filterOptions ', () => {
266266
it('should filter by input (case insensitive)', () => {
267267
const combobox = render(<Combobox options={OPTIONS} />);
268268

269-
const input = combobox.getByTestId('combobox-input');
269+
const input = combobox.getByTestId('react-gears-combobox-input');
270270
fireEvent.focus(input);
271271

272272
fireEvent.change(input, { target: { value: 'bb8' } });
@@ -278,7 +278,7 @@ describe('<Combobox />', () => {
278278
it('should update filtered options when input is updated', () => {
279279
const combobox = render(<Combobox options={OPTIONS} />);
280280

281-
const input = combobox.getByTestId('combobox-input');
281+
const input = combobox.getByTestId('react-gears-combobox-input');
282282
fireEvent.focus(input);
283283
fireEvent.change(input, { target: { value: 'd2' } });
284284

@@ -306,7 +306,7 @@ describe('<Combobox />', () => {
306306

307307
const combobox = render(<Combobox options={groupedOptions} />);
308308

309-
const input = combobox.getByTestId('combobox-input');
309+
const input = combobox.getByTestId('react-gears-combobox-input');
310310
fireEvent.focus(input);
311311

312312
const droidLabel = combobox.getByText('Droids');
@@ -335,7 +335,7 @@ describe('<Combobox />', () => {
335335
<Combobox options={OPTIONS} onChange={mockOnChange} onCreate={mockOnCreate} />
336336
);
337337

338-
const input = combobox.getByTestId('combobox-input');
338+
const input = combobox.getByTestId('react-gears-combobox-input');
339339
fireEvent.focus(input);
340340

341341
userEvent.type(input, 'new option');
@@ -360,18 +360,18 @@ describe('<Combobox />', () => {
360360
/>
361361
);
362362

363-
const input = combobox.getByTestId('combobox-input');
363+
const input = combobox.getByTestId('react-gears-combobox-input');
364364

365365
userEvent.type(input, 'new option');
366366

367-
let newOptionButton = combobox.getByTestId('create-new-option');
367+
let newOptionButton = combobox.getByTestId('react-gears-combobox-create-new-option');
368368

369369
assert(newOptionButton.hasAttribute('disabled'));
370370

371371
input.setSelectionRange(0, 'new option'.length);
372372
userEvent.type(input, 'foobar');
373373

374-
newOptionButton = combobox.getByTestId('create-new-option');
374+
newOptionButton = combobox.getByTestId('react-gears-combobox-create-new-option');
375375

376376
assert(!newOptionButton.hasAttribute('disabled'));
377377
});
@@ -393,7 +393,7 @@ describe('<Combobox />', () => {
393393
let combobox = render(
394394
<Combobox options={OPTIONS} onChange={mockOnChange} value={value} multi />
395395
);
396-
let input = combobox.getByTestId('combobox-input');
396+
let input = combobox.getByTestId('react-gears-combobox-input');
397397
fireEvent.focus(input);
398398

399399
const option1 = combobox.getByText('D-O');
@@ -409,7 +409,7 @@ describe('<Combobox />', () => {
409409

410410
cleanup();
411411
combobox = render(<Combobox options={OPTIONS} onChange={mockOnChange} value={value} multi />);
412-
input = combobox.getByTestId('combobox-input');
412+
input = combobox.getByTestId('react-gears-combobox-input');
413413

414414
fireEvent.keyDown(input, { key: 'Backspace', code: 8 });
415415

src/components/Combobox/Combobox.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function Combobox<T>({
305305
return (
306306
<DropdownItem
307307
active={noMatches}
308-
data-testid="create-new-option"
308+
data-testid="react-gears-combobox-create-new-option"
309309
disabled={!isValidNewOption(inputValue)}
310310
onMouseDown={(ev) => {
311311
ev.preventDefault();
@@ -353,7 +353,7 @@ function Combobox<T>({
353353
</div>
354354
)}
355355
<Dropdown
356-
data-testid="combobox-dropdown"
356+
data-testid="react-gears-combobox-dropdown"
357357
direction={direction}
358358
isOpen={!disabled && open}
359359
toggle={() => {}}
@@ -368,7 +368,7 @@ function Combobox<T>({
368368
<InputGroup className={className}>
369369
<Input
370370
innerRef={inputElement}
371-
data-testid="combobox-input"
371+
data-testid="react-gears-combobox-input"
372372
disabled={disabled}
373373
className={inputClassName}
374374
placeholder={selected ? undefined : placeholder}
@@ -408,7 +408,7 @@ function Combobox<T>({
408408
/>
409409
<Button
410410
className="px-2"
411-
data-testid="combobox-caret"
411+
data-testid="react-gears-combobox-caret"
412412
disabled={disabled}
413413
active={open}
414414
onMouseDown={(ev) => {
@@ -423,7 +423,7 @@ function Combobox<T>({
423423
</InputGroup>
424424
</DropdownToggle>
425425
<DropdownMenu
426-
data-testid="combobox-menu"
426+
data-testid="react-gears-combobox-menu"
427427
className="p-0 w-100"
428428
style={{ maxHeight: menuMaxHeight || '12rem', overflowY: 'auto' }}
429429
{...dropdownProps}

0 commit comments

Comments
 (0)