diff --git a/src/renderers/noop/__tests__/ReactNoop-test.js b/src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
similarity index 69%
rename from src/renderers/noop/__tests__/ReactNoop-test.js
rename to src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
index 1ce47ee5c2..cd54236258 100644
--- a/src/renderers/noop/__tests__/ReactNoop-test.js
+++ b/src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
@@ -15,7 +15,7 @@ var React;
var ReactNoop;
var ReactCoroutine;
-describe('ReactComponent', function() {
+describe('ReactCoroutine', function() {
beforeEach(function() {
React = require('React');
ReactNoop = require('ReactNoop');
@@ -23,61 +23,32 @@ describe('ReactComponent', function() {
spyOn(console, 'log');
});
- it('should render a simple component', function() {
-
- function Bar() {
- return
Hello World
;
- }
-
- function Foo() {
- return ;
- }
-
- ReactNoop.render();
- ReactNoop.flush();
-
- });
-
- it('should render a simple component, in steps if needed', function() {
-
- function Bar() {
- return Hello World
;
- }
-
- function Foo() {
- return [
- ,
- ,
- ];
- }
-
- ReactNoop.render();
- // console.log('Nothing done');
- ReactNoop.flushLowPri(7);
- // console.log('Yield');
- ReactNoop.flushLowPri(50);
- // console.log('Done');
- });
-
it('should render a coroutine', function() {
+ var ops = [];
+
+
function Continuation({ isSame }) {
+ ops.push(['Continuation', isSame]);
return {isSame ? 'foo==bar' : 'foo!=bar'};
}
// An alternative API could mark Continuation as something that needs
// yielding. E.g. Continuation.yieldType = 123;
function Child({ bar }) {
+ ops.push(['Child', bar]);
return ReactCoroutine.createYield({
bar: bar,
}, Continuation, null);
}
function Indirection() {
+ ops.push('Indirection');
return [, ];
}
function HandleYields(props, yields) {
+ ops.push('HandleYields');
return yields.map(y =>
);
@@ -86,6 +57,7 @@ describe('ReactComponent', function() {
// An alternative API could mark Parent as something that needs
// yielding. E.g. Parent.handler = HandleYields;
function Parent(props) {
+ ops.push('Parent');
return ReactCoroutine.createCoroutine(
props.children,
HandleYields,
@@ -100,6 +72,19 @@ describe('ReactComponent', function() {
ReactNoop.render();
ReactNoop.flush();
+ expect(ops).toEqual([
+ 'Parent',
+ 'Indirection',
+ ['Child', true],
+ // Yield
+ ['Child', false],
+ // Yield
+ 'HandleYields',
+ // Continue yields
+ ['Continuation', true],
+ ['Continuation', false],
+ ]);
+
});
});
diff --git a/src/renderers/shared/fiber/__tests__/ReactIncremental-test.js b/src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
new file mode 100644
index 0000000000..c0bc0abd32
--- /dev/null
+++ b/src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2013-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ * @emails react-core
+ */
+
+'use strict';
+
+var React;
+var ReactNoop;
+
+describe('ReactIncremental', function() {
+ beforeEach(function() {
+ React = require('React');
+ ReactNoop = require('ReactNoop');
+ spyOn(console, 'log');
+ });
+
+ it('should render a simple component', function() {
+
+ function Bar() {
+ return Hello World
;
+ }
+
+ function Foo() {
+ return ;
+ }
+
+ ReactNoop.render();
+ ReactNoop.flush();
+
+ });
+
+ it('should render a simple component, in steps if needed', function() {
+
+ var barCalled = false;
+ function Bar() {
+ barCalled = true;
+ return Hello World
;
+ }
+
+ var fooCalled = false;
+ function Foo() {
+ fooCalled = true;
+ return [
+ ,
+ ,
+ ];
+ }
+
+ ReactNoop.render();
+ expect(fooCalled).toBe(false);
+ expect(barCalled).toBe(false);
+ // Do one step of work.
+ ReactNoop.flushLowPri(7);
+ expect(fooCalled).toBe(true);
+ expect(barCalled).toBe(false);
+ // Do the rest of the work.
+ ReactNoop.flushLowPri(50);
+ expect(fooCalled).toBe(true);
+ expect(barCalled).toBe(true);
+ });
+
+});