-
Notifications
You must be signed in to change notification settings - Fork 47.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6931 from sebmarkbage/newreconciler
[Fiber] Simple test assertions (cherry picked from commit dc5686a)
- Loading branch information
1 parent
ab4ea74
commit 39ddfdd
Showing
2 changed files
with
90 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <div>Hello World</div>; | ||
} | ||
|
||
function Foo() { | ||
return <Bar isBar={true} />; | ||
} | ||
|
||
ReactNoop.render(<Foo />); | ||
ReactNoop.flush(); | ||
|
||
}); | ||
|
||
it('should render a simple component, in steps if needed', function() { | ||
|
||
var barCalled = false; | ||
function Bar() { | ||
barCalled = true; | ||
return <span><div>Hello World</div></span>; | ||
} | ||
|
||
var fooCalled = false; | ||
function Foo() { | ||
fooCalled = true; | ||
return [ | ||
<Bar isBar={true} />, | ||
<Bar isBar={true} />, | ||
]; | ||
} | ||
|
||
ReactNoop.render(<Foo />); | ||
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); | ||
}); | ||
|
||
}); |