Skip to content

Commit

Permalink
Added new failing tests (pending a separate fix to React)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Mar 10, 2020
1 parent 0ef4bdb commit 45ed506
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,39 @@ describe('useMutableSource', () => {
});
});

it('should recover from a mutation during yield when other work is scheduled', () => {
const source = createSource('one');
const mutableSource = createMutableSource(source);

act(() => {
// Start a render that uses the mutable source.
ReactNoop.render(
<>
<Component
label="a"
getSnapshot={defaultGetSnapshot}
mutableSource={mutableSource}
subscribe={defaultSubscribe}
/>
<Component
label="b"
getSnapshot={defaultGetSnapshot}
mutableSource={mutableSource}
subscribe={defaultSubscribe}
/>
</>,
);
expect(Scheduler).toFlushAndYieldThrough(['a:one']);

// Mutate source
source.value = 'two';

// Now render something different.
ReactNoop.render(<div />);
expect(Scheduler).toFlushAndYield([]);
});
});

it('should not throw if the new getSnapshot returns the same snapshot value', () => {
const source = createSource('one');
const mutableSource = createMutableSource(source);
Expand Down

0 comments on commit 45ed506

Please sign in to comment.