@samitouri / QOS-React / commits / a6728f961c

[Fiber] Add unit tests for ReactDOMFiber (#8016)

Toru Kobayashi committed Oct 21, 2016 at 13:44 UTC a6728f961cc1b91bcb3670ad5b91660ab5ad4281
1 file changed +68
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js new
+68
@@ -0,0 +1,68 @@
1 +/**
2 + * Copyright 2013-present, 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 + * @emails react-core
10 + */
11 +
12 +'use strict';
13 +
14 +var React = require('React');
15 +var ReactDOM = require('ReactDOM');
16 +var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
17 +
18 +describe('ReactDOMFiber', () => {
19 + var container;
20 +
21 + beforeEach(() => {
22 + container = document.createElement('div');
23 + });
24 +
25 + it('should render strings as children', () => {
26 + const Box = ({value}) => <div>{value}</div>;
27 +
28 + ReactDOM.render(
29 + <Box value="foo" />,
30 + container
31 + );
32 + expect(container.textContent).toEqual('foo');
33 + });
34 +
35 + it('should render numbers as children', () => {
36 + const Box = ({value}) => <div>{value}</div>;
37 +
38 + ReactDOM.render(
39 + <Box value={10} />,
40 + container
41 + );
42 +
43 + expect(container.textContent).toEqual('10');
44 + });
45 +
46 + if (ReactDOMFeatureFlags.useFiber) {
47 + it('should render a component returning strings directly from render', () => {
48 + const Text = ({value}) => value;
49 +
50 + ReactDOM.render(
51 + <Text value="foo" />,
52 + container
53 + );
54 + expect(container.textContent).toEqual('foo');
55 + });
56 +
57 + it('should render a component returning numbers directly from render', () => {
58 + const Text = ({value}) => value;
59 +
60 + ReactDOM.render(
61 + <Text value={10} />,
62 + container
63 + );
64 +
65 + expect(container.textContent).toEqual('10');
66 + });
67 + }
68 +});