Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Compensate for Circle CI's low performance #24358

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'docs/.next/**',
],
recursive: true,
timeout: (process.env.CIRCLECI === 'true' ? 3 : 2) * 1000, // Circle CI has low-performance CPUs.
reporter: 'dot',
require: [require.resolve('./test/utils/setupBabel'), require.resolve('./test/utils/setupJSDOM')],
'watch-ignore': [
Expand Down
36 changes: 23 additions & 13 deletions packages/material-ui/test/integration/MenuList.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 } from 'sinon';
import { spy, useFakeTimers } from 'sinon';
import MenuList from '@material-ui/core/MenuList';
import MenuItem from '@material-ui/core/MenuItem';
import Divider from '@material-ui/core/Divider';
Expand Down Expand Up @@ -541,21 +541,31 @@ describe('<MenuList> integration', () => {
expect(screen.getByText('Worm')).toHaveFocus();
});

it('should reset the character buffer after 500ms', (done) => {
render(
<MenuList autoFocus>
<MenuItem>Worm</MenuItem>
<MenuItem>Ordinary</MenuItem>
</MenuList>,
);
describe('time', () => {
let clock;
beforeEach(() => {
clock = useFakeTimers();
});

fireEvent.keyDown(screen.getByRole('menu'), { key: 'W' });
setTimeout(() => {
fireEvent.keyDown(screen.getByText('Worm'), { key: 'o' });
afterEach(() => {
act(() => {
clock.restore();
});
});

it('should reset the character buffer after 500ms', () => {
render(
<MenuList autoFocus>
<MenuItem>Worm</MenuItem>
<MenuItem>Ordinary</MenuItem>
</MenuList>,
);

fireEvent.keyDown(screen.getByRole('menu'), { key: 'W' });
clock.tick(501);
fireEvent.keyDown(screen.getByText('Worm'), { key: 'o' });
expect(screen.getByText('Ordinary')).toHaveFocus();
done();
}, 500);
});
});

it('should match ignoring hidden text', function testHiddenText() {
Expand Down