-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn about ReactDOM.createPortal usage within ReactTestRenderer
- Loading branch information
Brian Vaughn
committed
May 23, 2018
1 parent
fe747a5
commit 7d57c8a
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
packages/react-test-renderer/src/__tests__/ReactTestRenderer-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,27 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* 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 ReactDOM = require('react-dom'); | ||
|
||
// Isolate test renderer. | ||
jest.resetModules(); | ||
const ReactTestRenderer = require('react-test-renderer'); | ||
|
||
describe('ReactTestRenderer', () => { | ||
it('should warn if used to render a ReactDOM portal', () => { | ||
const container = document.createElement('div'); | ||
expect(() => { | ||
expect(() => { | ||
ReactTestRenderer.create(ReactDOM.createPortal('foo', container)); | ||
}).toThrow(); | ||
}).toWarnDev('An invalid container has been provided.'); | ||
}); | ||
}); |