forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up ReactDOMServerIntegrationForm-test (facebook#13600)
In facebook#13394, I encountered an issue where the ReactDOMServerIntegrationForm test suite consumed sufficient memory to crash CircleCI. Breaking up this test suite by form element type resolved the issue. This commit performs that change separate from the Symbol/Function stringification changes in facebook#13394.
- Loading branch information
Showing
7 changed files
with
944 additions
and
802 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
packages/react-dom/src/__tests__/ReactDOMServerIntegrationCheckbox-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); | ||
|
||
let React; | ||
let ReactDOM; | ||
let ReactDOMServer; | ||
|
||
function initModules() { | ||
// Reset warning cache. | ||
jest.resetModuleRegistry(); | ||
React = require('react'); | ||
ReactDOM = require('react-dom'); | ||
ReactDOMServer = require('react-dom/server'); | ||
|
||
// Make them available to the helpers. | ||
return { | ||
ReactDOM, | ||
ReactDOMServer, | ||
}; | ||
} | ||
|
||
const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); | ||
|
||
describe('ReactDOMServerIntegrationCheckbox', () => { | ||
beforeEach(() => { | ||
resetModules(); | ||
}); | ||
|
||
itRenders('a checkbox that is checked with an onChange', async render => { | ||
const e = await render( | ||
<input type="checkbox" checked={true} onChange={() => {}} />, | ||
); | ||
expect(e.checked).toBe(true); | ||
}); | ||
|
||
itRenders('a checkbox that is checked with readOnly', async render => { | ||
const e = await render( | ||
<input type="checkbox" checked={true} readOnly={true} />, | ||
); | ||
expect(e.checked).toBe(true); | ||
}); | ||
|
||
itRenders( | ||
'a checkbox that is checked and no onChange/readOnly', | ||
async render => { | ||
// this configuration should raise a dev warning that checked without | ||
// onChange or readOnly is a mistake. | ||
const e = await render(<input type="checkbox" checked={true} />, 1); | ||
expect(e.checked).toBe(true); | ||
}, | ||
); | ||
|
||
itRenders('a checkbox with defaultChecked', async render => { | ||
const e = await render(<input type="checkbox" defaultChecked={true} />); | ||
expect(e.checked).toBe(true); | ||
expect(e.getAttribute('defaultChecked')).toBe(null); | ||
}); | ||
|
||
itRenders('a checkbox checked overriding defaultChecked', async render => { | ||
const e = await render( | ||
<input | ||
type="checkbox" | ||
checked={true} | ||
defaultChecked={false} | ||
readOnly={true} | ||
/>, | ||
1, | ||
); | ||
expect(e.checked).toBe(true); | ||
expect(e.getAttribute('defaultChecked')).toBe(null); | ||
}); | ||
|
||
itRenders( | ||
'a checkbox checked overriding defaultChecked no matter the prop order', | ||
async render => { | ||
const e = await render( | ||
<input | ||
type="checkbox" | ||
defaultChecked={false} | ||
checked={true} | ||
readOnly={true} | ||
/>, | ||
1, | ||
); | ||
expect(e.checked).toBe(true); | ||
expect(e.getAttribute('defaultChecked')).toBe(null); | ||
}, | ||
); | ||
}); |
Oops, something went wrong.