Skip to content

Commit

Permalink
[test] Make tests oblivious to StrictMode (#26654)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jun 8, 2021
1 parent cf2f6fa commit a28a5e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions packages/material-ui/src/Popper/Popper.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy, useFakeTimers } from 'sinon';
import { useFakeTimers } from 'sinon';
import PropTypes from 'prop-types';
import {
createMount,
Expand Down Expand Up @@ -44,17 +44,15 @@ describe('<Popper />', () => {

describe('prop: placement', () => {
it('should have top placement', () => {
const renderSpy = spy();
render(
<Popper {...defaultProps} placement="top">
{({ placement }) => {
renderSpy(placement);
return null;
return <span data-testid="renderSpy" data-placement={placement} />;
}}
</Popper>,
);
expect(renderSpy.callCount).to.equal(2); // strict mode renders twice
expect(renderSpy.args[0][0]).to.equal('top');

expect(screen.getByTestId('renderSpy')).to.have.attribute('data-placement', 'top');
});

[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe('<TextareaAutosize />', () => {
scrollHeight: 100,
lineHeight: () => {
index += 1;
return 15 + index;
return index;
},
});

Expand Down
3 changes: 2 additions & 1 deletion test/utils/mochaHooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ describe('mochaHooks', () => {

describe('dedupes missing act() warnings by component', () => {
const mochaHooks = createMochaHooks(Mocha);
const render = createClientRender();
// missing act warnings only happen in StrictMode
const render = createClientRender({ strict: true });

beforeEach(function beforeEachHook() {
mochaHooks.beforeAll.forEach((beforeAllMochaHook) => {
Expand Down

0 comments on commit a28a5e7

Please sign in to comment.