[Fiber] Add a unit test for ReactTopLevelText (#8001)
Toru Kobayashi committed
Oct 19, 2016 at 03:39 UTC
3d7869ab0eab66184d979677acc834b8e45e5fd7
1 file changed
+39
src/renderers/shared/fiber/__tests__/ReactTopLevelText-test.js
new
+39
@@ -0,0 +1,39 @@
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;
15
+var ReactNoop;
16
+
17
+// This is a new feature in Fiber so I put it in its own test file. It could
18
+// probably move to one of the other test files once it is official.
19
+describe('ReactTopLevelText', () => {
20
+ beforeEach(() => {
21
+ React = require('React');
22
+ ReactNoop = require('ReactNoop');
23
+ });
24
+
25
+ it('should render a component returning strings directly from render', () => {
26
+ const Text = ({value}) => value;
27
+ ReactNoop.render(<Text value="foo" />);
28
+ ReactNoop.flush();
29
+ expect(ReactNoop.root.children).toEqual([{text: 'foo'}]);
30
+ });
31
+
32
+ it('should render a component returning numbers directly from render', () => {
33
+ const Text = ({value}) => value;
34
+ ReactNoop.render(<Text value={10} />);
35
+ ReactNoop.flush();
36
+ expect(ReactNoop.root.children).toEqual([{text: '10'}]);
37
+ });
38
+
39
+});