Skip to content

Commit

Permalink
Add test for then resolving synchronously for sync updates
Browse files Browse the repository at this point in the history
This is the main reason Work is a thenable and not a promise.
  • Loading branch information
acdlite committed Sep 29, 2017
1 parent a81fe25 commit 40806dc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMAsyncRoot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ describe('ReactDOMAsyncRoot', () => {

jest.runAllTimers();
});

it('resolves `then` callback synchronously if update is sync', () => {
const container = document.createElement('div');
const root = ReactDOM.unstable_createRoot(container);
const work = root.prerender(<div>Hi</div>);
work.then(() => {
work.commit();
expect(container.textContent).toEqual('Hi');
});
// `then` should have synchronously resolved
expect(container.textContent).toEqual('Hi');
});
} else {
it('does not apply to stack');
}
Expand Down

0 comments on commit 40806dc

Please sign in to comment.