Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosvega91 committed Apr 30, 2020
1 parent 46ac5dc commit 59a434b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 34 deletions.
48 changes: 29 additions & 19 deletions packages/material-ui-styles/src/makeStyles/makeStyles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('makeStyles', () => {
classes: { root: 'h1' },
});
const extendedClasses = output.classes;
expect(extendedClasses.root).to.equal( `${baseClasses.root} h1`);
expect(extendedClasses.root).to.equal(`${baseClasses.root} h1`);
});

it('should ignore undefined prop', () => {
Expand Down Expand Up @@ -91,16 +91,20 @@ describe('makeStyles', () => {
output.wrapper.setProps({ classes: { bar: 'foo' } });
const extendedClasses = output.classes;
expect(extendedClasses).to.deep.equal({ root: baseClasses.root, bar: 'undefined foo' });
expect(consoleErrorMock.callCount()).to.equal( 1);
expect(consoleErrorMock.messages()[0]).to.include('Material-UI: the key `bar` provided to the classes prop is not implemented');
expect(consoleErrorMock.callCount()).to.equal(1);
expect(consoleErrorMock.messages()[0]).to.include(
'Material-UI: the key `bar` provided to the classes prop is not implemented',
);
});

it('should warn if providing a string', () => {
const output = mountWithProps();
output.wrapper.setProps({ classes: 'foo' });
expect(consoleErrorMock.callCount() >= 1).to.equal(true);
const messages = consoleErrorMock.messages();
expect(messages[messages.length - 1]).to.include('You might want to use the className prop instead');
expect(messages[messages.length - 1]).to.include(
'You might want to use the className prop instead',
);
});

it('should warn if providing a non string', () => {
Expand All @@ -110,7 +114,9 @@ describe('makeStyles', () => {
const extendedClasses = output.classes;
expect(extendedClasses).to.deep.equal({ root: `${baseClasses.root} [object Object]` });
expect(consoleErrorMock.callCount()).to.equal(1);
expect(consoleErrorMock.messages()[0]).to.include('Material-UI: the key `root` provided to the classes prop is not valid');
expect(consoleErrorMock.messages()[0]).to.include(
'Material-UI: the key `root` provided to the classes prop is not valid',
);
});

it('should warn if missing theme', () => {
Expand All @@ -120,7 +126,9 @@ describe('makeStyles', () => {
mountWithProps2({});
}).to.throw();
expect(consoleErrorMock.callCount()).to.equal(4);
expect(consoleErrorMock.messages()[1]).to.include('the `styles` argument provided is invalid');
expect(consoleErrorMock.messages()[1]).to.include(
'the `styles` argument provided is invalid',
);
});
});

Expand Down Expand Up @@ -158,7 +166,7 @@ describe('makeStyles', () => {
const classes1 = output.classes;
expect(classes1).to.deep.equal({
root: `${classes.root} foo`,
})
});

output.wrapper.setProps({
classes: { root: 'bar' },
Expand All @@ -167,7 +175,7 @@ describe('makeStyles', () => {
expect(classes1).to.not.equal(classes2);
expect(classes2).to.deep.equal({
root: `${classes.root} bar`,
})
});
});
});

Expand Down Expand Up @@ -197,13 +205,13 @@ describe('makeStyles', () => {
</ThemeProvider>,
);
expect(sheetsRegistry.registry.length).to.equal(1);
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-1' })
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-1' });
wrapper.update();
expect(sheetsRegistry.registry.length).to.equal(1);
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-1' })
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-1' });
wrapper.setProps({ theme: createMuiTheme() });
expect(sheetsRegistry.registry.length).to.equal(1);
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-2' })
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-2' });

wrapper.unmount();
expect(sheetsRegistry.registry.length).to.equal(0);
Expand Down Expand Up @@ -335,17 +343,16 @@ describe('makeStyles', () => {
expect(sheetsRegistry.registry.length).to.equal(2);
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-1' });
expect(sheetsRegistry.registry[1].classes).to.deep.equal({ root: 'makeStyles-root-2' });
expect(sheetsRegistry.registry[1].rules.map.root.style).to.deep.equal( {
expect(sheetsRegistry.registry[1].rules.map.root.style).to.deep.equal({
margin: '8px',
padding: '8px',
});


wrapper.setProps({ padding: 4 });
expect(sheetsRegistry.registry.length).to.equal(2);
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-1' });
expect(sheetsRegistry.registry[1].classes).to.deep.equal({ root: 'makeStyles-root-2' });
expect(sheetsRegistry.registry[1].rules.map.root.style).to.deep.equal( {
expect(sheetsRegistry.registry[1].rules.map.root.style).to.deep.equal({
margin: '8px',
padding: '4px',
});
Expand Down Expand Up @@ -405,7 +412,6 @@ describe('makeStyles', () => {
root: { padding: 8 },
});


hmr = true;
wrapper.setProps({});
expect(sheetsRegistry.registry.length).to.equal(1);
Expand Down Expand Up @@ -528,23 +534,27 @@ describe('makeStyles', () => {
</StylesProvider>,
);
expect(sheetsRegistry.registry.length).to.equal(2);
expect(sheetsRegistry.toString() ).to.equal(`.makeStyles-root-2 {
expect(sheetsRegistry.toString()).to.equal(`.makeStyles-root-2 {
color: white;
background-color: black;
}`)
}`);

act(() => {
wrapper.find('#color').simulate('change', { target: { value: 'blue' } });
});
expect( sheetsRegistry.toString(), `.makeStyles-root-4 {
expect(
sheetsRegistry.toString(),
`.makeStyles-root-4 {
color: blue;
background-color: black;
}`,
);
act(() => {
wrapper.find('#background-color').simulate('change', { target: { value: 'green' } });
});
expect(sheetsRegistry.toString(), `.makeStyles-root-4 {
expect(
sheetsRegistry.toString(),
`.makeStyles-root-4 {
color: blue;
background-color: green;
}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Hidden/HiddenJs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('<HiddenJs />', () => {
<div>foo</div>
</HiddenJs>,
);
expect(wrapper.type()).to.not.equal(null)
expect(wrapper.type()).to.not.equal(null);
expect(wrapper.name()).to.equal('div');
expect(wrapper.first().text()).to.equal('foo');
});
Expand Down
4 changes: 3 additions & 1 deletion packages/material-ui/src/styles/createTypography.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ describe('createTypography', () => {

it('only defines letter-spacing if the font-family is not overwritten', () => {
expect(createTypography(palette, {}).h1.letterSpacing).to.not.equal(undefined);
expect(createTypography(palette, { fontFamily: 'Gotham' }).h1.letterSpacing).to.equal(undefined);
expect(createTypography(palette, { fontFamily: 'Gotham' }).h1.letterSpacing).to.equal(
undefined,
);
});

describe('warnings', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/material-ui/src/styles/responsiveFontSizes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('responsiveFontSizes', () => {
'@media (min-width:600px)': { fontSize: '4.75rem' },
'@media (min-width:960px)': { fontSize: '5.5rem' },
'@media (min-width:1280px)': { fontSize: defaultVariant.fontSize },
})
});
});

it('should disable vertical alignment', () => {
Expand Down Expand Up @@ -63,7 +63,9 @@ describe('responsiveFontSizes', () => {
},
},
});
expect(() => { responsiveFontSizes(theme) }).to.throw();
expect(() => {
responsiveFontSizes(theme);
}).to.throw();
});
});
});
22 changes: 11 additions & 11 deletions packages/material-ui/src/utils/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('utils/index.js', () => {
const wrapper = mount(<Component />);

expect(wrapper.containsMatchingElement(<div>true</div>)).to.equal(true);
expect(consoleErrorMock.callCount()).to.equal( 0);
expect(consoleErrorMock.callCount()).to.equal(0);
});

it('does nothing if none of the forked branches requires a ref', () => {
Expand All @@ -129,7 +129,7 @@ describe('utils/index.js', () => {
<Inner />
</Outer>,
);
expect(consoleErrorMock.callCount()).to.equal( 0);
expect(consoleErrorMock.callCount()).to.equal(0);
});

describe('changing refs', () => {
Expand All @@ -150,12 +150,12 @@ describe('utils/index.js', () => {
it('handles changing from no ref to some ref', () => {
const wrapper = mount(<Div id="test" />);

expect(consoleErrorMock.callCount()).to.equal( 0);
expect(consoleErrorMock.callCount()).to.equal(0);

const ref = React.createRef();
wrapper.setProps({ leftRef: ref });

expect(ref.current.id).to.equal( 'test');
expect(ref.current.id).to.equal('test');
expect(consoleErrorMock.callCount()).to.equal(0);
});

Expand All @@ -166,16 +166,16 @@ describe('utils/index.js', () => {

const wrapper = mount(<Div leftRef={firstLeftRef} rightRef={firstRightRef} id="test" />);

expect(consoleErrorMock.callCount()).to.equal( 0);
expect(firstLeftRef.current.id).to.equal( 'test');
expect(firstRightRef.current.id).to.equal( 'test');
expect(secondRightRef.current).to.equal( null);
expect(consoleErrorMock.callCount()).to.equal(0);
expect(firstLeftRef.current.id).to.equal('test');
expect(firstRightRef.current.id).to.equal('test');
expect(secondRightRef.current).to.equal(null);

wrapper.setProps({ rightRef: secondRightRef });

expect(firstLeftRef.current.id).to.equal( 'test');
expect(firstRightRef.current).to.equal( null);
expect(secondRightRef.current.id,).to.equal( 'test');
expect(firstLeftRef.current.id).to.equal('test');
expect(firstRightRef.current).to.equal(null);
expect(secondRightRef.current.id).to.equal('test');
});
});
});
Expand Down

0 comments on commit 59a434b

Please sign in to comment.