Skip to content

Commit 72ac760

Browse files
[test] Migrate from assert to expect (#20799)
1 parent d6faf6f commit 72ac760

File tree

115 files changed

+1543
-1777
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1543
-1777
lines changed

docs/src/modules/utils/helpers.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import { expect } from 'chai';
22
import { getDependencies } from './helpers';
33

44
describe('docs getDependencies helpers', () => {
@@ -21,7 +21,7 @@ const styles = theme => ({
2121
`;
2222

2323
it('should handle @ dependencies', () => {
24-
assert.deepEqual(getDependencies(s1), {
24+
expect(getDependencies(s1)).to.deep.equal({
2525
'@foo-bar/bip': 'latest',
2626
'@material-ui/core': 'latest',
2727
'prop-types': 'latest',
@@ -45,7 +45,7 @@ import { withStyles } from '@material-ui/core/styles';
4545
const suggestions = [
4646
`;
4747

48-
assert.deepEqual(getDependencies(source), {
48+
expect(getDependencies(source)).to.deep.equal({
4949
'@material-ui/core': 'latest',
5050
'@unexisting/thing': 'latest',
5151
'autosuggest-highlight': 'latest',
@@ -57,7 +57,7 @@ const suggestions = [
5757
});
5858

5959
it('should support next dependencies', () => {
60-
assert.deepEqual(getDependencies(s1, { reactVersion: 'next' }), {
60+
expect(getDependencies(s1, { reactVersion: 'next' })).to.deep.equal({
6161
'@foo-bar/bip': 'latest',
6262
'@material-ui/core': 'latest',
6363
'prop-types': 'latest',
@@ -77,7 +77,7 @@ import DateFnsUtils from '@date-io/date-fns';
7777
import { MuiPickersUtilsProvider, TimePicker, DatePicker } from '@material-ui/pickers';
7878
`;
7979

80-
assert.deepEqual(getDependencies(source), {
80+
expect(getDependencies(source)).to.deep.equal({
8181
'date-fns': 'latest',
8282
'@date-io/date-fns': 'v1',
8383
'@material-ui/pickers': 'latest',
@@ -89,7 +89,7 @@ import { MuiPickersUtilsProvider, TimePicker, DatePicker } from '@material-ui/pi
8989
});
9090

9191
it('can collect required @types packages', () => {
92-
assert.deepEqual(getDependencies(s1, { codeLanguage: 'TS' }), {
92+
expect(getDependencies(s1, { codeLanguage: 'TS' })).to.deep.equal({
9393
'@foo-bar/bip': 'latest',
9494
'@material-ui/core': 'latest',
9595
'prop-types': 'latest',
@@ -114,7 +114,7 @@ import {
114114
} from '@material-ui/pickers';
115115
`;
116116

117-
assert.deepEqual(getDependencies(source), {
117+
expect(getDependencies(source)).to.deep.equal({
118118
'date-fns': 'latest',
119119
'@material-ui/pickers': 'latest',
120120
react: 'latest',
@@ -127,7 +127,7 @@ import {
127127
import lab from '@material-ui/lab';
128128
`;
129129

130-
assert.deepEqual(getDependencies(source), {
130+
expect(getDependencies(source)).to.deep.equal({
131131
'@material-ui/core': 'latest',
132132
'@material-ui/lab': 'latest',
133133
react: 'latest',

packages/material-ui-icons/builder.test.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'chai';
1+
import { expect, assert } from 'chai';
22
import fs from 'fs';
33
import path from 'path';
44
import temp from 'temp';
@@ -22,16 +22,16 @@ describe('builder', () => {
2222

2323
describe('#getComponentName', () => {
2424
it('should change capitalize dashes', () => {
25-
assert.strictEqual(getComponentName('hi-world'), 'HiWorld', true);
25+
expect(getComponentName('hi-world')).to.equal('HiWorld');
2626
});
2727

2828
it('should capitalize based on environment path.sep', () => {
29-
assert.strictEqual(getComponentName(`this${path.sep}dir`), 'ThisDir', true);
29+
expect(getComponentName(`this${path.sep}dir`)).to.equal('ThisDir');
3030
});
3131
});
3232

3333
it('should have icons to test with', () => {
34-
assert.strictEqual(fs.lstatSync(MUI_ICONS_SVG_DIR).isDirectory(), true);
34+
expect(fs.lstatSync(MUI_ICONS_SVG_DIR).isDirectory()).to.equal(true);
3535
});
3636

3737
it('should have main', () => {
@@ -58,8 +58,8 @@ describe('builder', () => {
5858

5959
it('script outputs to directory', async () => {
6060
await main(options);
61-
assert.strictEqual(fs.lstatSync(options.outputDir).isDirectory(), true);
62-
assert.strictEqual(fs.lstatSync(path.join(options.outputDir, 'index.js')).isFile(), true);
61+
expect(fs.lstatSync(options.outputDir).isDirectory()).to.equal(true);
62+
expect(fs.lstatSync(path.join(options.outputDir, 'index.js')).isFile()).to.equal(true);
6363
});
6464
});
6565

@@ -83,11 +83,8 @@ describe('builder', () => {
8383

8484
it('script outputs to directory', async () => {
8585
await main(options);
86-
assert.strictEqual(fs.lstatSync(options.outputDir).isDirectory(), true);
87-
assert.strictEqual(
88-
fs.lstatSync(path.join(options.outputDir, 'delapouite')).isDirectory(),
89-
true,
90-
);
86+
expect(fs.lstatSync(options.outputDir).isDirectory()).to.equal(true);
87+
expect(fs.lstatSync(path.join(options.outputDir, 'delapouite')).isDirectory()).to.equal(true);
9188

9289
const actualFilePath = path.join(
9390
options.outputDir,
@@ -98,10 +95,10 @@ describe('builder', () => {
9895
'transparent',
9996
'Dice-six-faces-four.js',
10097
);
101-
assert.strictEqual(fs.existsSync(actualFilePath), true);
98+
expect(fs.existsSync(actualFilePath)).to.equal(true);
10299

103100
const actualFileData = fs.readFileSync(actualFilePath, { encoding: 'utf8' });
104-
assert.include(actualFileData, "import createSvgIcon from './utils/createSvgIcon'");
101+
expect(actualFileData).to.include("import createSvgIcon from './utils/createSvgIcon'");
105102
});
106103
});
107104

@@ -125,7 +122,7 @@ describe('builder', () => {
125122

126123
it('should produce the expected output', async () => {
127124
await main(options);
128-
assert.strictEqual(fs.lstatSync(options.outputDir).isDirectory(), true);
125+
expect(fs.lstatSync(options.outputDir).isDirectory()).to.equal(true);
129126

130127
const cases = [
131128
'Accessibility.js',
@@ -143,7 +140,7 @@ describe('builder', () => {
143140
encoding: 'utf8',
144141
});
145142

146-
assert.include(actual, expected);
143+
expect(actual).to.include(expected);
147144
});
148145
});
149146
});

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

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { assert } from 'chai';
2+
import { expect } from 'chai';
33
import { spy } from 'sinon';
44
import {
55
createMount,
@@ -56,7 +56,7 @@ describe('<SpeedDial />', () => {
5656
<FakeAction />
5757
</SpeedDial>,
5858
);
59-
assert.strictEqual(findOutermostIntrinsic(wrapper).type(), 'div');
59+
expect(findOutermostIntrinsic(wrapper).type()).to.equal('div');
6060
});
6161

6262
it('should render a Fab', () => {
@@ -66,7 +66,7 @@ describe('<SpeedDial />', () => {
6666
</SpeedDial>,
6767
);
6868
const buttonWrapper = wrapper.find('[aria-expanded]').first();
69-
assert.strictEqual(buttonWrapper.type(), Fab);
69+
expect(buttonWrapper.type()).to.equal(Fab);
7070
});
7171

7272
it('should render with a null child', () => {
@@ -77,7 +77,7 @@ describe('<SpeedDial />', () => {
7777
<SpeedDialAction icon={icon} tooltipTitle="Three" />
7878
</SpeedDial>,
7979
);
80-
assert.strictEqual(wrapper.find(SpeedDialAction).length, 2);
80+
expect(wrapper.find(SpeedDialAction).length).to.equal(2);
8181
});
8282

8383
it('should pass the open prop to its children', () => {
@@ -89,7 +89,7 @@ describe('<SpeedDial />', () => {
8989
</SpeedDial>,
9090
);
9191
const actions = wrapper.find('[role="menuitem"]').filterWhere(wrapsIntrinsicElement);
92-
assert.strictEqual(actions.some('.is-closed'), false);
92+
expect(actions.some('.is-closed')).to.equal(false);
9393
});
9494

9595
describe('prop: onKeyDown', () => {
@@ -106,8 +106,8 @@ describe('<SpeedDial />', () => {
106106
key: ' ',
107107
eventMock,
108108
});
109-
assert.strictEqual(handleKeyDown.callCount, 1);
110-
assert.strictEqual(handleKeyDown.calledWithMatch({ eventMock }), true);
109+
expect(handleKeyDown.callCount).to.equal(1);
110+
expect(handleKeyDown.calledWithMatch({ eventMock })).to.equal(true);
111111
});
112112
});
113113

@@ -120,7 +120,7 @@ describe('<SpeedDial />', () => {
120120
<SpeedDialAction icon={icon} tooltipTitle="action2" />
121121
</SpeedDial>,
122122
);
123-
assert.strictEqual(findOutermostIntrinsic(wrapper).hasClass(classes[className]), true);
123+
expect(findOutermostIntrinsic(wrapper).hasClass(classes[className])).to.equal(true);
124124
};
125125

126126
it('should place actions in correct position', () => {
@@ -204,20 +204,20 @@ describe('<SpeedDial />', () => {
204204

205205
it('displays the actions on focus gain', () => {
206206
resetDialToOpen();
207-
assert.strictEqual(wrapper.find(SpeedDial).props().open, true);
207+
expect(wrapper.find(SpeedDial).props().open).to.equal(true);
208208
});
209209

210210
describe('first item selection', () => {
211211
it('considers arrow keys with the same initial orientation', () => {
212212
resetDialToOpen();
213213
getDialButton().simulate('keydown', { key: 'left' });
214-
assert.strictEqual(isActionFocused(0), true);
214+
expect(isActionFocused(0)).to.equal(true);
215215
getDialButton().simulate('keydown', { key: 'up' });
216-
assert.strictEqual(isActionFocused(0), true);
216+
expect(isActionFocused(0)).to.equal(true);
217217
getDialButton().simulate('keydown', { key: 'left' });
218-
assert.strictEqual(isActionFocused(1), true);
218+
expect(isActionFocused(1)).to.equal(true);
219219
getDialButton().simulate('keydown', { key: 'right' });
220-
assert.strictEqual(isActionFocused(0), true);
220+
expect(isActionFocused(0)).to.equal(true);
221221
});
222222
});
223223

@@ -236,8 +236,7 @@ describe('<SpeedDial />', () => {
236236
resetDialToOpen(dialDirection);
237237

238238
getDialButton().simulate('keydown', { key: firstKey });
239-
assert.strictEqual(
240-
isActionFocused(firstFocusedAction),
239+
expect(isActionFocused(firstFocusedAction)).to.equal(
241240
true,
242241
`focused action initial ${firstKey} should be ${firstFocusedAction}`,
243242
);
@@ -250,8 +249,7 @@ describe('<SpeedDial />', () => {
250249
getActionButton(previousFocusedAction).simulate('keydown', {
251250
key: arrowKey,
252251
});
253-
assert.strictEqual(
254-
isActionFocused(expectedFocusedAction),
252+
expect(isActionFocused(expectedFocusedAction)).to.equal(
255253
true,
256254
`focused action after ${combinationUntilNot.join(
257255
',',

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { assert } from 'chai';
2+
import { expect } from 'chai';
33
import { createMount, getClasses } from '@material-ui/core/test-utils';
44
import Icon from '@material-ui/core/Icon';
55
import Tooltip from '@material-ui/core/Tooltip';
@@ -38,24 +38,24 @@ describe('<SpeedDialAction />', () => {
3838
const wrapper = mount(
3939
<SpeedDialAction {...defaultProps} TooltipClasses={{ tooltip: 'bar' }} />,
4040
);
41-
assert.include(wrapper.find(Tooltip).props().classes.tooltip, 'bar');
41+
expect(wrapper.find(Tooltip).props().classes.tooltip).to.include('bar');
4242
});
4343

4444
it('should render a Fab', () => {
4545
const wrapper = mount(<SpeedDialAction {...defaultProps} />);
46-
assert.strictEqual(wrapper.find(Fab).exists(), true);
46+
expect(wrapper.find(Fab).exists()).to.equal(true);
4747
});
4848

4949
it('should render the button with the fab class', () => {
5050
const wrapper = mount(<SpeedDialAction {...defaultProps} open />);
5151
const buttonWrapper = wrapper.find('button');
52-
assert.strictEqual(buttonWrapper.hasClass(classes.fab), true);
52+
expect(buttonWrapper.hasClass(classes.fab)).to.equal(true);
5353
});
5454

5555
it('should render the button with the fab and fabClosed classes', () => {
5656
const wrapper = mount(<SpeedDialAction {...defaultProps} />);
5757
const buttonWrapper = wrapper.find('button');
58-
assert.strictEqual(buttonWrapper.hasClass(classes.fab), true);
59-
assert.strictEqual(buttonWrapper.hasClass(classes.fabClosed), true);
58+
expect(buttonWrapper.hasClass(classes.fab)).to.equal(true);
59+
expect(buttonWrapper.hasClass(classes.fabClosed)).to.equal(true);
6060
});
6161
});

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

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { assert } from 'chai';
2+
import { expect } from 'chai';
33
import { createMount, getClasses, findOutermostIntrinsic } from '@material-ui/core/test-utils';
44
import Icon from '@material-ui/core/Icon';
55
import SpeedDialIcon from './SpeedDialIcon';
@@ -29,59 +29,56 @@ describe('<SpeedDialIcon />', () => {
2929

3030
it('should render the Add icon by default', () => {
3131
const wrapper = mount(<SpeedDialIcon />);
32-
assert.strictEqual(
33-
findOutermostIntrinsic(wrapper).find('svg[data-mui-test="AddIcon"]').length,
34-
1,
35-
);
32+
expect(findOutermostIntrinsic(wrapper).find('svg[data-mui-test="AddIcon"]').length).to.equal(1);
3633
});
3734

3835
it('should render an Icon', () => {
3936
const wrapper = mount(<SpeedDialIcon icon={icon} />);
4037
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(0);
41-
assert.strictEqual(iconWrapper.find(Icon).length, 1);
38+
expect(iconWrapper.find(Icon).length).to.equal(1);
4239
});
4340

4441
it('should render an openIcon', () => {
4542
const wrapper = mount(<SpeedDialIcon openIcon={icon} />);
4643
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(0);
47-
assert.strictEqual(iconWrapper.find(Icon).length, 1);
44+
expect(iconWrapper.find(Icon).length).to.equal(1);
4845
});
4946

5047
it('should render the icon with the icon class', () => {
5148
const wrapper = mount(<SpeedDialIcon />);
5249
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(0);
53-
assert.strictEqual(iconWrapper.hasClass(classes.icon), true);
54-
assert.strictEqual(iconWrapper.hasClass(classes.iconOpen), false);
55-
assert.strictEqual(iconWrapper.hasClass(classes.iconWithOpenIconOpen), false);
50+
expect(iconWrapper.hasClass(classes.icon)).to.equal(true);
51+
expect(iconWrapper.hasClass(classes.iconOpen)).to.equal(false);
52+
expect(iconWrapper.hasClass(classes.iconWithOpenIconOpen)).to.equal(false);
5653
});
5754

5855
it('should render the icon with the icon and iconOpen classes', () => {
5956
const wrapper = mount(<SpeedDialIcon open />);
6057
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(0);
61-
assert.strictEqual(iconWrapper.hasClass(classes.icon), true);
62-
assert.strictEqual(iconWrapper.hasClass(classes.iconOpen), true);
63-
assert.strictEqual(iconWrapper.hasClass(classes.iconWithOpenIconOpen), false);
58+
expect(iconWrapper.hasClass(classes.icon)).to.equal(true);
59+
expect(iconWrapper.hasClass(classes.iconOpen)).to.equal(true);
60+
expect(iconWrapper.hasClass(classes.iconWithOpenIconOpen)).to.equal(false);
6461
});
6562

6663
it('should render the icon with the icon, iconOpen iconWithOpenIconOpen classes', () => {
6764
const wrapper = mount(<SpeedDialIcon open openIcon={icon} />);
6865
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(1);
69-
assert.strictEqual(iconWrapper.hasClass(classes.icon), true);
70-
assert.strictEqual(iconWrapper.hasClass(classes.iconOpen), true);
71-
assert.strictEqual(iconWrapper.hasClass(classes.iconWithOpenIconOpen), true);
66+
expect(iconWrapper.hasClass(classes.icon)).to.equal(true);
67+
expect(iconWrapper.hasClass(classes.iconOpen)).to.equal(true);
68+
expect(iconWrapper.hasClass(classes.iconWithOpenIconOpen)).to.equal(true);
7269
});
7370

7471
it('should render the openIcon with the openIcon class', () => {
7572
const wrapper = mount(<SpeedDialIcon openIcon={icon} />);
7673
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(0);
77-
assert.strictEqual(iconWrapper.hasClass(classes.openIcon), true);
78-
assert.strictEqual(iconWrapper.hasClass(classes.openIconOpen), false);
74+
expect(iconWrapper.hasClass(classes.openIcon)).to.equal(true);
75+
expect(iconWrapper.hasClass(classes.openIconOpen)).to.equal(false);
7976
});
8077

8178
it('should render the openIcon with the openIcon, openIconOpen classes', () => {
8279
const wrapper = mount(<SpeedDialIcon open openIcon={icon} />);
8380
const iconWrapper = findOutermostIntrinsic(wrapper).childAt(0);
84-
assert.strictEqual(iconWrapper.hasClass(classes.openIcon), true);
85-
assert.strictEqual(iconWrapper.hasClass(classes.openIconOpen), true);
81+
expect(iconWrapper.hasClass(classes.openIcon)).to.equal(true);
82+
expect(iconWrapper.hasClass(classes.openIconOpen)).to.equal(true);
8683
});
8784
});

0 commit comments

Comments
 (0)