Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
6c806ff
[test] Add conformance test suite
eps1lon Nov 23, 2018
2597ec4
[test] Add ref forwarding to conformance test
eps1lon Dec 1, 2018
7f9fbb5
[test] Improve props spreading test
eps1lon Dec 2, 2018
fb38ed0
[test] Allow to test for multiple default classes
eps1lon Dec 2, 2018
d1ac097
[test] Use standard css class testint utils
eps1lon Dec 2, 2018
19b7574
[test] Decouple from display name but rather use type
eps1lon Mar 19, 2019
17e241e
[test] cleanup describeConformance
eps1lon Mar 19, 2019
3e60412
[test] use stronger wording in describeConformance
eps1lon Mar 19, 2019
39d8f13
[test] Go back to describeConformance inheritComponentName
eps1lon Mar 19, 2019
e13fcee
[test] Use common `root` class as a default className
eps1lon Mar 19, 2019
4065d0a
[test] Strict mode compliant testComponentProp
eps1lon Mar 19, 2019
2757a1b
[test] use default testComponentPropWith
eps1lon Mar 19, 2019
ee5102e
[test] Remove whitelist for describeConformance
eps1lon Mar 19, 2019
f4cab8b
[test] noForwardRef -> forwardRef
eps1lon Mar 19, 2019
6f56532
Update packages/material-ui/src/test-utils/describeConformance.js
oliviertassinari Mar 20, 2019
b9bab06
[test] More accurate ref forwarding test
eps1lon Mar 21, 2019
d5c59fe
[test] Get options for conformance suite lazily
eps1lon Mar 21, 2019
e750500
[test] Make describePerformance more robust
eps1lon Mar 22, 2019
688fec8
[Toolbar] Test conformance
eps1lon Mar 21, 2019
5fc4dc9
[TextField] Test conformance
eps1lon Mar 21, 2019
c6de1fb
[Tabs] Test conformance
eps1lon Mar 21, 2019
251474b
[TableSortLabel] Test conformance
eps1lon Mar 21, 2019
74a505d
[TableRow] test conformance
eps1lon Mar 21, 2019
6d27132
[TableHead] Fix conformance
eps1lon Mar 21, 2019
5cd32b5
[TableCell] Test conformance
eps1lon Mar 21, 2019
7aab1b8
[TableFooter] Test conformance
eps1lon Mar 21, 2019
a2038ee
[TableBody] Test conformance
eps1lon Mar 21, 2019
0fd748c
[Table] Test conformance
eps1lon Mar 21, 2019
d22563d
[Tab] Test conformance
eps1lon Mar 21, 2019
165d4a8
[SvgIcon] Test conformance
eps1lon Mar 22, 2019
a2a2a9a
[Stepper] Test conformance
eps1lon Mar 22, 2019
003d962
[StepLabel] Test conformance
eps1lon Mar 22, 2019
646fbfe
[StepContent] Test conformance
eps1lon Mar 22, 2019
dc668bb
[StepConnector] Test conformance
eps1lon Mar 22, 2019
b849d94
[StepButton] Test conformance
eps1lon Mar 22, 2019
e706a3f
[Step] Test conformance
eps1lon Mar 22, 2019
75e4b09
[test] Don't test component if not required
eps1lon Mar 22, 2019
f3ad7da
[SnackbarContent] Test conformance
eps1lon Mar 22, 2019
cb1520e
[Snackbar] Test conformance
eps1lon Mar 22, 2019
7b1f952
[Radio] Test conformance
eps1lon Mar 23, 2019
3ee9597
[Paper] Test conformance
eps1lon Mar 23, 2019
5c399c2
[Modal] Test conformance
eps1lon Mar 23, 2019
9548a49
[MobileStepper] Test conformance
eps1lon Mar 23, 2019
3d4fbda
[MenuItem] Test conformance
eps1lon Mar 23, 2019
cbbc672
[ListSubheader] Test conformance
eps1lon Mar 23, 2019
0576fbe
[ListItemText] Test conformance
eps1lon Mar 23, 2019
b815dda
[ListitemSecondaryAction] Test conformance
eps1lon Mar 23, 2019
21cdd6a
[ListItemIcon] Test conformance
eps1lon Mar 23, 2019
8930151
[ListItem] Test conformance
eps1lon Mar 23, 2019
625b53b
[List] Test conformance
eps1lon Mar 23, 2019
4d619f2
[Link] Test conformance
eps1lon Mar 23, 2019
697db86
[LinearProgress] Test conformance
eps1lon Mar 26, 2019
cb6ba14
[InputLabel] Test conformance
eps1lon Mar 26, 2019
f074609
[InputBase] Test conformance
eps1lon Mar 26, 2019
b632afb
[InputAdornment] Test conformance
eps1lon Mar 26, 2019
ec3847a
[IconButton] Test conformance
eps1lon Mar 26, 2019
e911823
[Icon] Test conformance
eps1lon Mar 26, 2019
1330066
[GridListTileBar] Test conformance
eps1lon Mar 26, 2019
2fdfcc1
[GridListTile] Test conformance
eps1lon Mar 26, 2019
80c1ebf
[GridList] Test conformance
eps1lon Mar 26, 2019
8964a7d
[FormLabel] Test conformance
eps1lon Mar 26, 2019
6eccf34
[FormHelperText] Test conformance
eps1lon Mar 26, 2019
6594150
[FormGroup] Test conformance
eps1lon Mar 26, 2019
b04e7f9
[FormControlLabel] Test conformance
eps1lon Mar 26, 2019
3e22f01
[FormControl] Test conformance
eps1lon Mar 26, 2019
76cd363
[Fab] Test conformance
eps1lon Mar 26, 2019
096093d
[ExpansionPanelSummary] Test conformance
eps1lon Mar 26, 2019
d282b26
[ExpansionPanelDetails] Test conformance
eps1lon Mar 26, 2019
60f480b
[ExpansionPanelActions] Test conformance
eps1lon Mar 26, 2019
16d565c
[ExpansionPanel] Test conformance
eps1lon Mar 26, 2019
fe29edd
[Drawer] Test conformance
eps1lon Mar 26, 2019
4413fbd
[Divider] Test conformance
eps1lon Mar 26, 2019
1cdd4b4
[DialogTitle] Test conformance
eps1lon Mar 26, 2019
2aafe2a
[DialogContent] Test conformance
eps1lon Mar 26, 2019
56974e7
[DialogActions] Test conformance
eps1lon Mar 26, 2019
8620908
[Dialog] Test conformance
eps1lon Mar 26, 2019
1d1b43b
[CircularProgress] Test conformance
eps1lon Mar 26, 2019
2db01f7
[Chip] Test conformance
eps1lon Mar 26, 2019
cd4d1bd
[Checkbox] Test conformance
eps1lon Mar 26, 2019
953a7ed
[CardMedia] Test conformance
eps1lon Mar 26, 2019
6f2b173
[CardHeader] Test conformance
eps1lon Mar 26, 2019
e676b27
[CardContent] Test conformance
eps1lon Mar 26, 2019
1cdf1a8
[CardActions] Test conformance
eps1lon Mar 26, 2019
226aa63
[CardActionArea] Test conformance
eps1lon Mar 26, 2019
1515d49
[Card] Test conformance
eps1lon Mar 26, 2019
4d7fff0
[ButtonBase] Test conformance
eps1lon Mar 26, 2019
83a68f9
[Button] Test conformance
eps1lon Mar 26, 2019
c4cdb88
[BreadCrumbs] Test conformance
eps1lon Mar 26, 2019
d633852
[test] Remove redundant assertion message
eps1lon Mar 26, 2019
c519632
[BottomNavigationAction] Test conformance
eps1lon Mar 26, 2019
e092097
[BottomNavigation] Test conformance
eps1lon Mar 26, 2019
419f217
[Badge] Test conformance
eps1lon Mar 26, 2019
4d92271
[Avatar] Test conformance
eps1lon Mar 26, 2019
3921a41
[AppBar] Test conformance
eps1lon Mar 26, 2019
bd6253e
[test] Cleanup mount after test
eps1lon Mar 26, 2019
4836f6e
[test] Test actual ref
eps1lon Mar 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ describe('<ToggleButton />', () => {
classes = getClasses(<ToggleButton value="classes">Hello World</ToggleButton>);
});

after(() => {
mount.cleanUp();
});

it('does forward refs', () => {
testRef(<ToggleButton value="classes">Hello World</ToggleButton>, mount);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ describe('<ToggleButtonGroup />', () => {
);
});

after(() => {
mount.cleanUp();
});

function findToggleButton(wrapper, value) {
return wrapper
.find(ToggleButton)
Expand Down
30 changes: 19 additions & 11 deletions packages/material-ui/src/AppBar/AppBar.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
import React from 'react';
import { assert } from 'chai';
import { createShallow, getClasses } from '@material-ui/core/test-utils';
import {
createMount,
createShallow,
describeConformance,
getClasses,
} from '@material-ui/core/test-utils';
import AppBar from './AppBar';
import Paper from '../Paper';

describe('<AppBar />', () => {
let mount;
let shallow;
let classes;

before(() => {
mount = createMount();
shallow = createShallow({ dive: true });
classes = getClasses(<AppBar>Hello World</AppBar>);
});

it('should render a Paper component', () => {
const wrapper = shallow(<AppBar>Hello World</AppBar>);
assert.strictEqual(wrapper.props().elevation, 4);
after(() => {
mount.cleanUp();
});

describeConformance(<AppBar>Conformance?</AppBar>, () => ({
classes,
inheritComponent: Paper,
mount,
refInstanceof: window.HTMLElement,
testComponentPropWith: false,
}));

it('should render with the root class and primary', () => {
const wrapper = shallow(<AppBar>Hello World</AppBar>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true);
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false);
});

it('should render the custom className and the appBar class', () => {
const wrapper = shallow(<AppBar className="test-class-name">Hello World</AppBar>);
assert.strictEqual(wrapper.is('.test-class-name'), true);
assert.strictEqual(wrapper.hasClass(classes.root), true);
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true);
});

it('should render a primary app bar', () => {
const wrapper = shallow(<AppBar color="primary">Hello World</AppBar>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
Expand Down
21 changes: 20 additions & 1 deletion packages/material-ui/src/Avatar/Avatar.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
import React from 'react';
import { assert } from 'chai';
import CancelIcon from '../internal/svg-icons/Cancel';
import { createShallow, getClasses } from '@material-ui/core/test-utils';
import {
createMount,
createShallow,
describeConformance,
getClasses,
} from '@material-ui/core/test-utils';
import Avatar from './Avatar';

describe('<Avatar />', () => {
let mount;
let shallow;
let classes;

before(() => {
mount = createMount();
shallow = createShallow({ dive: true });
classes = getClasses(<Avatar />);
});

after(() => {
mount.cleanUp();
});

describeConformance(<Avatar />, () => ({
classes,
inheritComponent: 'div',
mount,
refInstanceof: window.HTMLDivElement,
testComponentPropWith: 'span',
}));

describe('image avatar', () => {
it('should render a div containing an img', () => {
const wrapper = shallow(
Expand Down
26 changes: 25 additions & 1 deletion packages/material-ui/src/Badge/Badge.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
import React from 'react';
import { assert } from 'chai';
import { createShallow, getClasses } from '@material-ui/core/test-utils';
import {
createMount,
createShallow,
describeConformance,
getClasses,
} from '@material-ui/core/test-utils';
import Badge from './Badge';

describe('<Badge />', () => {
let mount;
let shallow;
let classes;

before(() => {
mount = createMount();
shallow = createShallow({ dive: true });
classes = getClasses(<Badge badgeContent={1}>Hello World</Badge>);
});

after(() => {
mount.cleanUp();
});

describeConformance(
<Badge>
<div />
</Badge>,
() => ({
classes,
inheritComponent: 'span',
mount,
refInstanceof: window.HTMLSpanElement,
testComponentPropWith: 'div',
}),
);

const testChildren = <div className="unique">Hello World</div>;

it('renders children and badgeContent', () => {
Expand Down
40 changes: 19 additions & 21 deletions packages/material-ui/src/BottomNavigation/BottomNavigation.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react';
import { assert } from 'chai';
import { spy } from 'sinon';
import { createShallow, createMount, getClasses } from '@material-ui/core/test-utils';
import {
createShallow,
createMount,
describeConformance,
getClasses,
} from '@material-ui/core/test-utils';
import BottomNavigationAction from '../BottomNavigationAction';
import Icon from '../Icon';
import BottomNavigation from './BottomNavigation';
Expand All @@ -26,6 +31,19 @@ describe('<BottomNavigation />', () => {
mount.cleanUp();
});

describeConformance(
<BottomNavigation>
<BottomNavigationAction label="One" />
</BottomNavigation>,
() => ({
classes,
inheritComponent: 'div',
mount,
refInstanceof: window.HTMLDivElement,
testComponentPropWith: 'span',
}),
);

it('renders with a null child', () => {
const wrapper = shallow(
<BottomNavigation showLabels value={0}>
Expand All @@ -37,26 +55,6 @@ describe('<BottomNavigation />', () => {
assert.strictEqual(wrapper.find(BottomNavigationAction).length, 2);
});

it('should render with the root class', () => {
const wrapper = shallow(
<BottomNavigation showLabels value={0}>
<BottomNavigationAction icon={icon} />
</BottomNavigation>,
);
assert.strictEqual(wrapper.name(), 'div');
assert.strictEqual(wrapper.hasClass(classes.root), true);
});

it('should render with the user and root classes', () => {
const wrapper = shallow(
<BottomNavigation showLabels value={0} className="woofBottomNavigation">
<BottomNavigationAction icon={icon} />
</BottomNavigation>,
);
assert.strictEqual(wrapper.hasClass('woofBottomNavigation'), true);
assert.strictEqual(wrapper.hasClass(classes.root), true);
});

it('should pass selected prop to children', () => {
const wrapper = shallow(
<BottomNavigation showLabels value={1}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react';
import { assert } from 'chai';
import { spy } from 'sinon';
import { createMount, findOutermostIntrinsic, getClasses } from '@material-ui/core/test-utils';
import {
createMount,
describeConformance,
findOutermostIntrinsic,
getClasses,
} from '@material-ui/core/test-utils';
import ButtonBase from '../ButtonBase';
import Icon from '../Icon';
import BottomNavigationAction from './BottomNavigationAction';
Expand All @@ -16,21 +21,17 @@ describe('<BottomNavigationAction />', () => {
classes = getClasses(<BottomNavigationAction />);
});

it('should render a ButtonBase', () => {
const wrapper = mount(<BottomNavigationAction icon={icon} />);
const root = wrapper.find(`.${classes.root}`).first();
assert.strictEqual(root.exists(), true);
assert.strictEqual(root.type(), ButtonBase);
after(() => {
mount.cleanUp();
});

it('should render with the user and root classes', () => {
const wrapper = mount(
<BottomNavigationAction className="woofBottomNavigationAction" icon={icon} />,
);
const root = wrapper.find(`.${classes.root}.woofBottomNavigationAction`).first();
assert.strictEqual(root.exists(), true);
assert.strictEqual(root.hasClass('woofBottomNavigationAction'), true);
});
describeConformance(<BottomNavigationAction />, () => ({
classes,
inheritComponent: ButtonBase,
mount,
refInstanceof: window.HTMLButtonElement,
testComponentPropWith: false,
}));

it('should render with the selected and root classes', () => {
const wrapper = mount(<BottomNavigationAction icon={icon} selected />);
Expand Down
36 changes: 8 additions & 28 deletions packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { assert } from 'chai';
import { createMount, getClasses, findOutermostIntrinsic } from '@material-ui/core/test-utils';
import { createMount, describeConformance, getClasses } from '@material-ui/core/test-utils';
import Breadcrumbs from './Breadcrumbs';
import BreadcrumbSeparator from './BreadcrumbSeparator';
import BreadcrumbCollapsed from './BreadcrumbCollapsed';
Expand All @@ -23,33 +23,13 @@ describe('<Breadcrumbs />', () => {
mount.cleanUp();
});

it('should render a <nav> element', () => {
const wrapper = mount(
<Breadcrumbs>
<span>Hello World</span>
</Breadcrumbs>,
);
assert.strictEqual(findOutermostIntrinsic(wrapper).type(), 'nav');
});

it('should render the root class', () => {
const wrapper = mount(
<Breadcrumbs className="test-class-name">
<span>Hello World</span>
</Breadcrumbs>,
);
assert.strictEqual(findOutermostIntrinsic(wrapper).hasClass(classes.root), true);
});

it('should render the custom className and the root class', () => {
const wrapper = mount(
<Breadcrumbs className="test-class-name">
<span>Hello World</span>
</Breadcrumbs>,
);
assert.strictEqual(findOutermostIntrinsic(wrapper).is('.test-class-name'), true);
assert.strictEqual(findOutermostIntrinsic(wrapper).hasClass(classes.root), true);
});
describeConformance(<Breadcrumbs>Conformance?</Breadcrumbs>, () => ({
classes,
inheritComponent: 'nav',
mount,
refInstanceof: window.HTMLElement,
testComponentPropWith: 'div',
}));

it('should render seperators', () => {
const wrapper = mount(
Expand Down
30 changes: 19 additions & 11 deletions packages/material-ui/src/Button/Button.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
import React from 'react';
import { assert } from 'chai';
import { createShallow, createRender, getClasses } from '@material-ui/core/test-utils';
import {
createMount,
createShallow,
createRender,
describeConformance,
getClasses,
} from '@material-ui/core/test-utils';
import Button from './Button';
import ButtonBase from '../ButtonBase';
import Icon from '../Icon';

describe('<Button />', () => {
let mount;
let shallow;
let render;
let classes;

before(() => {
mount = createMount();
shallow = createShallow({ dive: true });
render = createRender();
classes = getClasses(<Button>Hello World</Button>);
});

it('should render a <ButtonBase> element', () => {
const wrapper = shallow(<Button>Hello World</Button>);
assert.strictEqual(wrapper.type(), ButtonBase);
assert.strictEqual(wrapper.props().type, 'button');
after(() => {
mount.cleanUp();
});

describeConformance(<Button>Conformance?</Button>, () => ({
classes,
inheritComponent: ButtonBase,
mount,
refInstanceof: window.HTMLButtonElement,
testComponentPropWith: false,
}));

it('should render with the root & text classes but no others', () => {
const wrapper = shallow(<Button>Hello World</Button>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
Expand All @@ -38,12 +52,6 @@ describe('<Button />', () => {
assert.strictEqual(wrapper.hasClass(classes.sizeLarge), false);
});

it('should render the custom className and the root class', () => {
const wrapper = shallow(<Button className="test-class-name">Hello World</Button>);
assert.strictEqual(wrapper.is('.test-class-name'), true);
assert.strictEqual(wrapper.hasClass(classes.root), true);
});

it('should render a text primary button', () => {
const wrapper = shallow(<Button color="primary">Hello World</Button>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
Expand Down
Loading