Skip to content

Commit 971d971

Browse files
group related tests
1 parent 0fd0242 commit 971d971

File tree

2 files changed

+21
-84
lines changed

2 files changed

+21
-84
lines changed

packages/material-ui-lab/src/Autocomplete/Autocomplete.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export const styles = theme => ({
4040
inputRoot: {
4141
flexWrap: 'wrap',
4242
'$hasPopupIcon &, $hasClearIcon &': {
43-
paddingRight: 31,
43+
paddingRight: 26 + 4,
4444
},
4545
'$hasPopupIcon$hasClearIcon &': {
46-
paddingRight: 62,
46+
paddingRight: 52 + 4,
4747
},
4848
'& $input': {
4949
width: 0,
@@ -69,10 +69,10 @@ export const styles = theme => ({
6969
'&[class*="MuiOutlinedInput-root"]': {
7070
padding: 9,
7171
'$hasPopupIcon &, $hasClearIcon &': {
72-
paddingRight: 31,
72+
paddingRight: 26 + 4 + 9,
7373
},
7474
'$hasPopupIcon$hasClearIcon &': {
75-
paddingRight: 62,
75+
paddingRight: 52 + 4 + 9,
7676
},
7777
'& $input': {
7878
padding: '9.5px 4px',
@@ -81,29 +81,29 @@ export const styles = theme => ({
8181
paddingLeft: 6,
8282
},
8383
'& $endAdornment': {
84-
right: 7,
84+
right: 9,
8585
},
8686
},
8787
'&[class*="MuiOutlinedInput-root"][class*="MuiOutlinedInput-marginDense"]': {
8888
padding: 6,
89-
'$hasPopupIcon &, $hasClearIcon &': {
90-
paddingRight: 31,
91-
},
92-
'$hasPopupIcon$hasClearIcon &': {
93-
paddingRight: 62,
94-
},
9589
'& $input': {
9690
padding: '4.5px 4px',
9791
},
9892
},
9993
'&[class*="MuiFilledInput-root"]': {
10094
paddingTop: 19,
10195
paddingLeft: 8,
96+
'$hasPopupIcon &, $hasClearIcon &': {
97+
paddingRight: 26 + 4 + 9,
98+
},
99+
'$hasPopupIcon$hasClearIcon &': {
100+
paddingRight: 52 + 4 + 9,
101+
},
102102
'& $input': {
103103
padding: '9px 4px',
104104
},
105105
'& $endAdornment': {
106-
right: 7,
106+
right: 9,
107107
},
108108
},
109109
'&[class*="MuiFilledInput-root"][class*="MuiFilledInput-marginDense"]': {

packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createClientRender, fireEvent } from 'test/utils/createClientRender';
88
import Autocomplete from './Autocomplete';
99
import TextField from '@material-ui/core/TextField';
1010

11-
describe('<Autocomplete />', () => {
11+
describe.only('<Autocomplete />', () => {
1212
let mount;
1313
let classes;
1414
const render = createClientRender();
@@ -40,22 +40,12 @@ describe('<Autocomplete />', () => {
4040
expect(input.value).to.equal('');
4141
});
4242

43-
it('should apply the hasClearIcon class', () => {
43+
it('should apply the icon classes', () => {
4444
const { container } = render(
4545
<Autocomplete renderInput={params => <TextField {...params} />} />,
4646
);
47-
expect(container.querySelector('[class*="MuiAutocomplete-root"]')).to.have.class(
48-
classes.hasClearIcon,
49-
);
50-
});
51-
52-
it('should apply the hasPopupIcon class', () => {
53-
const { container } = render(
54-
<Autocomplete renderInput={params => <TextField {...params} />} />,
55-
);
56-
expect(container.querySelector('[class*="MuiAutocomplete-root"]')).to.have.class(
57-
classes.hasPopupIcon,
58-
);
47+
expect(container.querySelector(`.${classes.root}`)).to.have.class(classes.hasClearIcon);
48+
expect(container.querySelector(`.${classes.root}`)).to.have.class(classes.hasPopupIcon);
5949
});
6050
});
6151

@@ -574,61 +564,23 @@ describe('<Autocomplete />', () => {
574564
renderInput={params => <TextField {...params} />}
575565
/>,
576566
);
577-
expect(container.querySelector('[class*="MuiAutocomplete-root"]')).not.to.have.class(
578-
classes.hasClearIcon,
579-
);
580-
});
581-
582-
it('should still apply the hasPopupIcon class', () => {
583-
const { container } = render(
584-
<Autocomplete
585-
disabled
586-
options={['one', 'two', 'three']}
587-
renderInput={params => <TextField {...params} />}
588-
/>,
589-
);
590-
expect(container.querySelector('[class*="MuiAutocomplete-root"]')).to.have.class(
591-
classes.hasPopupIcon,
592-
);
567+
expect(container.querySelector(`.${classes.root}`)).not.to.have.class(classes.hasClearIcon);
568+
expect(container.querySelector(`.${classes.root}`)).to.have.class(classes.hasPopupIcon);
593569
});
594570
});
595571

596572
describe('prop: disableClearable', () => {
597573
it('should not render the clear button', () => {
598-
const { queryByTitle } = render(
574+
const { queryByTitle, container } = render(
599575
<Autocomplete
600576
disableClearable
601577
options={['one', 'two', 'three']}
602578
renderInput={params => <TextField {...params} />}
603579
/>,
604580
);
605581
expect(queryByTitle('Clear')).to.be.null;
606-
});
607-
608-
it('should still apply the hasPopupIcon class', () => {
609-
const { container } = render(
610-
<Autocomplete
611-
disableClearable
612-
options={['one', 'two', 'three']}
613-
renderInput={params => <TextField {...params} />}
614-
/>,
615-
);
616-
expect(container.querySelector('[class*="MuiAutocomplete-root"]')).to.have.class(
617-
classes.hasPopupIcon,
618-
);
619-
});
620-
621-
it('should not apply the hasClearIcon class', () => {
622-
const { container } = render(
623-
<Autocomplete
624-
disableClearable
625-
options={['one', 'two', 'three']}
626-
renderInput={params => <TextField {...params} />}
627-
/>,
628-
);
629-
expect(container.querySelector('[class*="MuiAutocomplete-root"]')).not.to.have.class(
630-
classes.hasClearIcon,
631-
);
582+
expect(container.querySelector(`.${classes.root}`)).to.have.class(classes.hasPopupIcon);
583+
expect(container.querySelector(`.${classes.root}`)).not.to.have.class(classes.hasClearIcon);
632584
});
633585
});
634586
});
@@ -918,21 +870,6 @@ describe('<Autocomplete />', () => {
918870
fireEvent.keyDown(document.activeElement, { key: 'Enter' });
919871
expect(container.querySelectorAll('[class*="MuiChip-root"]')).to.have.length(3);
920872
});
921-
922-
it('should not apply hasPopupIcon class', () => {
923-
const handleChange = spy();
924-
const options = [{ name: 'foo' }];
925-
const { container } = render(
926-
<Autocomplete
927-
freeSolo
928-
onChange={handleChange}
929-
options={options}
930-
getOptionLabel={option => option.name}
931-
renderInput={params => <TextField {...params} autoFocus />}
932-
/>,
933-
);
934-
expect(container).not.to.have.class(classes.hasPopupIcon);
935-
});
936873
});
937874

938875
describe('prop: onInputChange', () => {

0 commit comments

Comments
 (0)