forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiple-copies-of-react-test.js
33 lines (29 loc) · 1 KB
/
multiple-copies-of-react-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* 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';
let React = require('react');
var ReactTestUtils = require('react-dom/test-utils');
class TextWithStringRef extends React.Component {
render() {
jest.resetModules();
React = require('react');
return <span ref="foo">Hello world!</span>;
}
}
describe('when different React version is used with string ref', () => {
it('throws the "Refs must have owner" warning', () => {
expect(() => {
ReactTestUtils.renderIntoDocument(<TextWithStringRef />);
}).toThrow(
'Element ref was specified as a string (foo) but no owner was set. ' +
"You may be adding a ref to a component that was not created inside a component's render method, or " +
'you have multiple copies of React loaded. (details: https://fb.me/react-refs-must-have-owner).',
);
});
});