@samitouri / QOS-React-2 / commits / ac17bdaaba

Remove `generateFromMetadata` and `getMetadata` usage.

cpojer committed Oct 28, 2015 at 23:38 UTC ac17bdaaba19c83d8a7c1c668cd0b21bd690b65e
8 files changed +62 -50
mocks/ReactElementTestChild.js new
+22
@@ -0,0 +1,22 @@
1 +/**
2 + * Copyright 2013-2015, Facebook, Inc.
3 + * All rights reserved.
4 + *
5 + * This source code is licensed under the BSD-style license found in the
6 + * LICENSE file in the root directory of this source tree. An additional grant
7 + * of patent rights can be found in the PATENTS file in the same directory.
8 + *
9 + * @providesModule ReactElementTestChild
10 + */
11 +
12 +'use strict';
13 +
14 +var React = require('React');
15 +
16 +var Child = React.createClass({
17 + render: function() {
18 + return React.createElement('div');
19 + },
20 +});
21 +
22 +module.exports = Child;
mocks/ReactMockedComponentTestComponent.js new
+35
@@ -0,0 +1,35 @@
1 +/**
2 + * Copyright 2013-2015, Facebook, Inc.
3 + * All rights reserved.
4 + *
5 + * This source code is licensed under the BSD-style license found in the
6 + * LICENSE file in the root directory of this source tree. An additional grant
7 + * of patent rights can be found in the PATENTS file in the same directory.
8 + *
9 + * @providesModule ReactMockedComponentTestComponent
10 + */
11 +
12 +'use strict';
13 +
14 +var React = require('React');
15 +
16 +var ReactMockedComponentTestComponent = React.createClass({
17 + getDefaultProps: function() {
18 + return {bar: 'baz'};
19 + },
20 +
21 + getInitialState: function() {
22 + return {foo: 'bar'};
23 + },
24 +
25 + hasCustomMethod: function() {
26 + return true;
27 + },
28 +
29 + render: function() {
30 + return <span />;
31 + },
32 +
33 +});
34 +
35 +module.exports = ReactMockedComponentTestComponent;
package.json
+1
@@ -70,6 +70,7 @@
70 ],
71 "testPathDirs": [
72 "<rootDir>/eslint-rules",
73 + "<rootDir>/mocks",
74 "<rootDir>/src",
75 "node_modules/fbjs"
76 ],
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+2 -11
@@ -369,23 +369,14 @@ describe('ReactElement', function() {
369 });
370
371 describe('comparing jsx vs .createFactory() vs .createElement()', function() {
372 - var Child, mocks;
372 + var Child;
373
374 beforeEach(function() {
375 jest.resetModuleRegistry();
376 - mocks = require('mocks');
376 React = require('React');
377 ReactDOM = require('ReactDOM');
378 ReactTestUtils = require('ReactTestUtils');
380 -
381 - var metaData = mocks.getMetadata(React.createClass({
382 - render: function() {
383 - return React.createElement('div');
384 - },
385 - }));
386 -
387 - Child = mocks.generateFromMetadata(metaData);
388 -
379 + Child = jest.genMockFromModule('ReactElementTestChild');
380 });
381
382
src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
-4
@@ -15,8 +15,6 @@ describe('DOMPropertyOperations', function() {
15 var DOMPropertyOperations;
16 var DOMProperty;
17
18 - var mocks;
19 -
18 beforeEach(function() {
19 jest.resetModuleRegistry();
20 var ReactDefaultInjection = require('ReactDefaultInjection');
@@ -24,8 +22,6 @@ describe('DOMPropertyOperations', function() {
22
23 DOMPropertyOperations = require('DOMPropertyOperations');
24 DOMProperty = require('DOMProperty');
27 -
28 - mocks = require('mocks');
25 });
26
27 describe('createMarkupForProperty', function() {
src/renderers/shared/reconciler/__tests__/ReactComponent-test.js
-3
@@ -15,11 +15,8 @@ var React;
15 var ReactDOM;
16 var ReactTestUtils;
17
18 -var mocks;
19 -
18 describe('ReactComponent', function() {
19 beforeEach(function() {
22 - mocks = require('mocks');
20 React = require('React');
21 ReactDOM = require('ReactDOM');
22 ReactTestUtils = require('ReactTestUtils');
src/renderers/shared/reconciler/__tests__/ReactMockedComponent-test.js
+2 -28
@@ -14,43 +14,17 @@
14 var React;
15 var ReactTestUtils;
16
17 -var mocks;
18 -
19 -var OriginalComponent;
17 var AutoMockedComponent;
18 var MockedComponent;
19
20 describe('ReactMockedComponent', function() {
21
22 beforeEach(function() {
26 - mocks = require('mocks');
27 -
23 React = require('React');
24 ReactTestUtils = require('ReactTestUtils');
25
31 - OriginalComponent = React.createClass({
32 - getDefaultProps: function() {
33 - return {bar: 'baz'};
34 - },
35 -
36 - getInitialState: function() {
37 - return {foo: 'bar'};
38 - },
39 -
40 - hasCustomMethod: function() {
41 - return true;
42 - },
43 -
44 - render: function() {
45 - return <span />;
46 - },
47 -
48 - });
49 -
50 - var metaData = mocks.getMetadata(OriginalComponent);
51 -
52 - AutoMockedComponent = mocks.generateFromMetadata(metaData);
53 - MockedComponent = mocks.generateFromMetadata(metaData);
26 + AutoMockedComponent = jest.genMockFromModule('ReactMockedComponentTestComponent');
27 + MockedComponent = jest.genMockFromModule('ReactMockedComponentTestComponent');
28
29 ReactTestUtils.mockComponent(MockedComponent);
30 });
src/test/__tests__/ReactTestUtils-test.js
-4
@@ -16,13 +16,9 @@ var ReactDOM;
16 var ReactDOMServer;
17 var ReactTestUtils;
18
19 -var mocks;
20 -
19 describe('ReactTestUtils', function() {
20
21 beforeEach(function() {
24 - mocks = require('mocks');
25 -
22 React = require('React');
23 ReactDOM = require('ReactDOM');
24 ReactDOMServer = require('ReactDOMServer');