Skip to content

Commit

Permalink
Add test for unmount/remount in a single batch (#8470)
Browse files Browse the repository at this point in the history
Fails in Fiber.
  • Loading branch information
sophiebits authored Dec 1, 2016
1 parent df9dc89 commit 361ce5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ src/renderers/shared/shared/__tests__/ReactUpdates-test.js
* throws in setState if the update callback is not a function
* throws in replaceState if the update callback is not a function
* throws in forceUpdate if the update callback is not a function
* unmounts and remounts a root in the same batch

src/renderers/shared/shared/__tests__/refs-test.js
* Should increase refs with an increase in divs
Expand Down
10 changes: 10 additions & 0 deletions src/renderers/shared/shared/__tests__/ReactUpdates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1081,4 +1081,14 @@ describe('ReactUpdates', () => {
});
expect(result).toEqual(42);
});

it('unmounts and remounts a root in the same batch', () => {
var container = document.createElement('div');
ReactDOM.render(<span>a</span>, container);
ReactDOM.unstable_batchedUpdates(function() {
ReactDOM.unmountComponentAtNode(container);
ReactDOM.render(<span>b</span>, container);
});
expect(container.textContent).toBe('b');
});
});

5 comments on commit 361ce5c

@zzz6519003
Copy link
Contributor

@zzz6519003 zzz6519003 commented on 361ce5c Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey man! fiber is developed under TDD right? Are those test in this repo(fiber) already OK?

@gaearon
Copy link
Collaborator

@gaearon gaearon commented on 361ce5c Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zzz6519003
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man you are awesome:beer:

@zzz6519003
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facebook is already done with the fiber test right?

@gaearon
Copy link
Collaborator

@gaearon gaearon commented on 361ce5c Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean—there's still quite a bit of work to do.
#7925

Please sign in to comment.