Skip to content

Commit 7dfa6bf

Browse files
authored
Change selector for customInputs in unit tests (wojtekmaj#89)
1 parent 11f04df commit 7dfa6bf

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

src/TimeInput.spec.jsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('TimeInput', () => {
5959
);
6060

6161
const nativeInput = component.find('input[type="time"]');
62-
const customInputs = component.find('input[type="number"]');
62+
const customInputs = component.find('input[data-input]');
6363

6464
expect(nativeInput).toHaveLength(1);
6565
expect(customInputs).toHaveLength(2);
@@ -73,7 +73,7 @@ describe('TimeInput', () => {
7373
/>
7474
);
7575

76-
const customInputs = component.find('input[type="number"]');
76+
const customInputs = component.find('input[data-input]');
7777
const secondInput = customInputs.find('input[name="second"]');
7878
const minuteInput = customInputs.find('input[name="minute"]');
7979
const hourInput = customInputs.find('input[name^="hour"]');
@@ -92,7 +92,7 @@ describe('TimeInput', () => {
9292
/>
9393
);
9494

95-
const customInputs = component.find('input[type="number"]');
95+
const customInputs = component.find('input[data-input]');
9696
const secondInput = customInputs.find('input[name="second"]');
9797
const minuteInput = customInputs.find('input[name="minute"]');
9898
const hourInput = customInputs.find('input[name^="hour"]');
@@ -115,7 +115,7 @@ describe('TimeInput', () => {
115115
);
116116

117117
const nativeInput = component.find('input[type="time"]');
118-
const customInputs = component.find('input[type="number"]');
118+
const customInputs = component.find('input[data-input]');
119119

120120
expect(nativeInput.prop('value')).toBe(date);
121121
expect(customInputs.at(0).prop('value')).toBe(10);
@@ -136,7 +136,7 @@ describe('TimeInput', () => {
136136
);
137137

138138
const nativeInput = component.find('input[type="time"]');
139-
const customInputs = component.find('input[type="number"]');
139+
const customInputs = component.find('input[data-input]');
140140

141141
expect(nativeInput.prop('value')).toBe(date);
142142
expect(customInputs.at(0).prop('value')).toBe(22);
@@ -154,7 +154,7 @@ describe('TimeInput', () => {
154154
);
155155

156156
const nativeInput = component.find('input[type="time"]');
157-
const customInputs = component.find('input[type="number"]');
157+
const customInputs = component.find('input[data-input]');
158158

159159
expect(nativeInput.prop('value')).toBeFalsy();
160160
expect(customInputs.at(0).prop('value')).toBeFalsy();
@@ -176,7 +176,7 @@ describe('TimeInput', () => {
176176
component.setProps({ value: null });
177177

178178
const nativeInput = component.find('input[type="time"]');
179-
const customInputs = component.find('input[type="number"]');
179+
const customInputs = component.find('input[data-input]');
180180

181181
expect(nativeInput.prop('value')).toBeFalsy();
182182
expect(customInputs.at(0).prop('value')).toBeFalsy();
@@ -192,7 +192,7 @@ describe('TimeInput', () => {
192192
/>
193193
);
194194

195-
const customInputs = component.find('input[type="number"]');
195+
const customInputs = component.find('input[data-input]');
196196

197197
expect(customInputs.at(0).prop('name')).toBe('hour12');
198198
expect(customInputs.at(1).prop('name')).toBe('minute');
@@ -208,7 +208,7 @@ describe('TimeInput', () => {
208208
/>
209209
);
210210

211-
const customInputs = component.find('input[type="number"]');
211+
const customInputs = component.find('input[data-input]');
212212

213213
expect(customInputs.at(0).prop('name')).toBe('hour24');
214214
expect(customInputs.at(1).prop('name')).toBe('minute');
@@ -264,7 +264,7 @@ describe('TimeInput', () => {
264264
);
265265

266266
const componentInput = component.find('Hour12Input');
267-
const customInputs = component.find('input[type="number"]');
267+
const customInputs = component.find('input[data-input]');
268268

269269
expect(componentInput).toHaveLength(1);
270270
expect(customInputs).toHaveLength(1);
@@ -279,7 +279,7 @@ describe('TimeInput', () => {
279279
);
280280

281281
const componentInput = component.find('Hour12Input');
282-
const customInputs = component.find('input[type="number"]');
282+
const customInputs = component.find('input[data-input]');
283283

284284
expect(componentInput).toHaveLength(1);
285285
expect(customInputs).toHaveLength(1);
@@ -310,7 +310,7 @@ describe('TimeInput', () => {
310310
);
311311

312312
const componentInput = component.find('Hour24Input');
313-
const customInputs = component.find('input[type="number"]');
313+
const customInputs = component.find('input[data-input]');
314314

315315
expect(componentInput).toHaveLength(1);
316316
expect(customInputs).toHaveLength(1);
@@ -325,7 +325,7 @@ describe('TimeInput', () => {
325325
);
326326

327327
const componentInput = component.find('Hour24Input');
328-
const customInputs = component.find('input[type="number"]');
328+
const customInputs = component.find('input[data-input]');
329329

330330
expect(componentInput).toHaveLength(1);
331331
expect(customInputs).toHaveLength(1);
@@ -356,7 +356,7 @@ describe('TimeInput', () => {
356356
);
357357

358358
const componentInput = component.find('MinuteInput');
359-
const customInputs = component.find('input[type="number"]');
359+
const customInputs = component.find('input[data-input]');
360360

361361
expect(componentInput).toHaveLength(1);
362362
expect(customInputs).toHaveLength(1);
@@ -371,7 +371,7 @@ describe('TimeInput', () => {
371371
);
372372

373373
const componentInput = component.find('MinuteInput');
374-
const customInputs = component.find('input[type="number"]');
374+
const customInputs = component.find('input[data-input]');
375375

376376
expect(componentInput).toHaveLength(1);
377377
expect(customInputs).toHaveLength(1);
@@ -402,7 +402,7 @@ describe('TimeInput', () => {
402402
);
403403

404404
const componentInput = component.find('SecondInput');
405-
const customInputs = component.find('input[type="number"]');
405+
const customInputs = component.find('input[data-input]');
406406

407407
expect(componentInput).toHaveLength(1);
408408
expect(customInputs).toHaveLength(1);
@@ -417,7 +417,7 @@ describe('TimeInput', () => {
417417
);
418418

419419
const componentInput = component.find('SecondInput');
420-
const customInputs = component.find('input[type="number"]');
420+
const customInputs = component.find('input[data-input]');
421421

422422
expect(componentInput).toHaveLength(1);
423423
expect(customInputs).toHaveLength(1);
@@ -448,7 +448,7 @@ describe('TimeInput', () => {
448448
);
449449

450450
const componentInput = component.find('AmPm');
451-
const customInputs = component.find('input[type="number"]');
451+
const customInputs = component.find('input[data-input]');
452452

453453
expect(componentInput).toHaveLength(1);
454454
expect(customInputs).toHaveLength(0);
@@ -477,7 +477,7 @@ describe('TimeInput', () => {
477477
);
478478

479479
const separators = component.find('.react-time-picker__inputGroup__divider');
480-
const customInputs = component.find('input[type="number"]');
480+
const customInputs = component.find('input[data-input]');
481481
const ampm = component.find('select');
482482

483483
expect(separators).toHaveLength(customInputs.length + ampm.length - 1);
@@ -492,7 +492,7 @@ describe('TimeInput', () => {
492492
{ attachTo: container }
493493
);
494494

495-
const customInputs = component.find('input[type="number"]');
495+
const customInputs = component.find('input[data-input]');
496496
const hourInput = customInputs.at(0);
497497
const minuteInput = customInputs.at(1);
498498

@@ -514,7 +514,7 @@ describe('TimeInput', () => {
514514
{ attachTo: container }
515515
);
516516

517-
const customInputs = component.find('input[type="number"]');
517+
const customInputs = component.find('input[data-input]');
518518
const hourInput = customInputs.at(0);
519519
const minuteInput = customInputs.at(1);
520520

@@ -558,7 +558,7 @@ describe('TimeInput', () => {
558558
{ attachTo: container }
559559
);
560560

561-
const customInputs = component.find('input[type="number"]');
561+
const customInputs = component.find('input[data-input]');
562562
const hourInput = customInputs.at(0);
563563
const minuteInput = customInputs.at(1);
564564

@@ -580,7 +580,7 @@ describe('TimeInput', () => {
580580
{ attachTo: container }
581581
);
582582

583-
const customInputs = component.find('input[type="number"]');
583+
const customInputs = component.find('input[data-input]');
584584
const hourInput = customInputs.at(0);
585585

586586
hourInput.getDOMNode().focus();
@@ -598,7 +598,7 @@ describe('TimeInput', () => {
598598
{ attachTo: container }
599599
);
600600

601-
const customInputs = component.find('input[type="number"]');
601+
const customInputs = component.find('input[data-input]');
602602
const hourInput = customInputs.at(0);
603603
const minuteInput = customInputs.at(1);
604604

@@ -616,7 +616,7 @@ describe('TimeInput', () => {
616616
{ attachTo: container }
617617
);
618618

619-
const customInputs = component.find('input[type="number"]');
619+
const customInputs = component.find('input[data-input]');
620620
const hourInput = customInputs.at(0);
621621
const minuteInput = customInputs.at(1);
622622

@@ -634,7 +634,7 @@ describe('TimeInput', () => {
634634
{ attachTo: container }
635635
);
636636

637-
const customInputs = component.find('input[type="number"]');
637+
const customInputs = component.find('input[data-input]');
638638
const hourInput = customInputs.at(0);
639639

640640
hourInput.getDOMNode().focus();
@@ -658,7 +658,7 @@ describe('TimeInput', () => {
658658
/>
659659
);
660660

661-
const customInputs = component.find('input[type="number"]');
661+
const customInputs = component.find('input[data-input]');
662662

663663
customInputs.at(0).getDOMNode().value = '20';
664664
customInputs.at(0).simulate('change');
@@ -680,7 +680,7 @@ describe('TimeInput', () => {
680680
/>
681681
);
682682

683-
const customInputs = component.find('input[type="number"]');
683+
const customInputs = component.find('input[data-input]');
684684

685685
customInputs.forEach((customInput) => {
686686
customInput.getDOMNode().value = ''; // eslint-disable-line no-param-reassign

src/TimeInput/Input.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default function Input({
9393
`${className}__${nameForClass || name}`,
9494
hasLeadingZero && `${className}__input--hasLeadingZero`,
9595
)}
96+
data-input="true"
9697
disabled={disabled}
9798
max={max}
9899
min={min}

src/TimePicker.spec.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describe('TimePicker', () => {
324324
<TimePicker isOpen />
325325
);
326326

327-
const customInputs = component.find('input[type="number"]');
327+
const customInputs = component.find('input[data-input]');
328328
const hourInput = customInputs.at(0);
329329
const minuteInput = customInputs.at(1);
330330

0 commit comments

Comments
 (0)