Skip to content

Commit 297165f

Browse files
committed
Port tests to old API
1 parent cd5b895 commit 297165f

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,41 +1886,42 @@ describe('ReactHooksWithNoopRenderer', () => {
18861886
// This reducer closes over a value from props. If the reducer is not
18871887
// properly updated, the eager reducer will compare to an old value
18881888
// and bail out incorrectly.
1889-
Scheduler.yieldValue('Reducer: ' + count);
1889+
ReactNoop.yield('Reducer: ' + count);
18901890
return count;
18911891
}, -1);
18921892
useEffect(
18931893
() => {
1894-
Scheduler.yieldValue('Effect: ' + count);
1894+
ReactNoop.yield('Effect: ' + count);
18951895
dispatch();
18961896
},
18971897
[count],
18981898
);
1899-
Scheduler.yieldValue('Render: ' + state);
1900-
return count;
1899+
ReactNoop.yield('Render: ' + state);
1900+
return <span prop={count} />;
19011901
}
19021902

19031903
ReactNoop.render(<App />);
1904-
expect(Scheduler).toFlushAndYield([
1905-
'Render: -1',
1904+
expect(ReactNoop.flush()).toEqual(['Render: -1']);
1905+
ReactNoop.flushPassiveEffects();
1906+
expect(ReactNoop.flush()).toEqual([
19061907
'Effect: 1',
19071908
'Reducer: 1',
19081909
'Reducer: 1',
19091910
'Render: 1',
19101911
]);
1911-
expect(ReactNoop).toMatchRenderedOutput('1');
1912+
expect(ReactNoop.getChildren()).toEqual([span(1)]);
19121913

19131914
act(() => {
19141915
setCounter(2);
19151916
});
1916-
expect(Scheduler).toFlushAndYield([
1917+
expect(ReactNoop.flush()).toEqual([
19171918
'Render: 1',
19181919
'Effect: 2',
19191920
'Reducer: 2',
19201921
'Reducer: 2',
19211922
'Render: 2',
19221923
]);
1923-
expect(ReactNoop).toMatchRenderedOutput('2');
1924+
expect(ReactNoop.getChildren()).toEqual([span(2)]);
19241925
});
19251926

19261927
it('should update latest rendered reducer when a preceding state receives a render phase update', () => {
@@ -1936,23 +1937,23 @@ describe('ReactHooksWithNoopRenderer', () => {
19361937
setStep(step + 1);
19371938
}
19381939

1939-
Scheduler.yieldValue(`Step: ${step}, Shadow: ${shadow}`);
1940-
return shadow;
1940+
ReactNoop.yield(`Step: ${step}, Shadow: ${shadow}`);
1941+
return <span prop={shadow} />;
19411942
}
19421943

19431944
ReactNoop.render(<App />);
1944-
expect(Scheduler).toFlushAndYield([
1945+
expect(ReactNoop.flush()).toEqual([
19451946
'Step: 0, Shadow: 0',
19461947
'Step: 1, Shadow: 0',
19471948
'Step: 2, Shadow: 0',
19481949
'Step: 3, Shadow: 0',
19491950
'Step: 4, Shadow: 0',
19501951
'Step: 5, Shadow: 0',
19511952
]);
1952-
expect(ReactNoop).toMatchRenderedOutput('0');
1953+
expect(ReactNoop.getChildren()).toEqual([span(0)]);
19531954

19541955
act(() => dispatch());
1955-
expect(Scheduler).toFlushAndYield(['Step: 5, Shadow: 5']);
1956-
expect(ReactNoop).toMatchRenderedOutput('5');
1956+
expect(ReactNoop.flush()).toEqual(['Step: 5, Shadow: 5']);
1957+
expect(ReactNoop.getChildren()).toEqual([span(5)]);
19571958
});
19581959
});

0 commit comments

Comments
 (0)