Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('ReactHooksInspectionIntegration', () => {
ReactDebugTools = require('react-debug-tools');
});

it('should inspect the current state of useState hooks', () => {
it('should inspect the current state of useState hooks', async () => {
const useState = React.useState;
function Foo(props) {
const [state1, setState1] = useState('hello');
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('ReactHooksInspectionIntegration', () => {
const {onMouseDown: setStateA, onMouseUp: setStateB} =
renderer.root.findByType('div').props;

act(() => setStateA('Hi'));
await act(async () => setStateA('Hi'));

childFiber = renderer.root.findByType(Foo)._currentFiber();
tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
Expand All @@ -83,7 +83,7 @@ describe('ReactHooksInspectionIntegration', () => {
},
]);

act(() => setStateB('world!'));
await act(async () => setStateB('world!'));

childFiber = renderer.root.findByType(Foo)._currentFiber();
tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
Expand All @@ -106,7 +106,7 @@ describe('ReactHooksInspectionIntegration', () => {
]);
});

it('should inspect the current state of all stateful hooks', () => {
it('should inspect the current state of all stateful hooks', async () => {
const outsideRef = React.createRef();
function effect() {}
function Foo(props) {
Expand All @@ -129,12 +129,8 @@ describe('ReactHooksInspectionIntegration', () => {
React.useMemo(() => state1 + state2, [state1]);

function update() {
act(() => {
setState('A');
});
act(() => {
dispatch({value: 'B'});
});
setState('A');
dispatch({value: 'B'});
ref.current = 'C';
}
const memoizedUpdate = React.useCallback(update, []);
Expand All @@ -145,7 +141,7 @@ describe('ReactHooksInspectionIntegration', () => {
);
}
let renderer;
act(() => {
await act(async () => {
renderer = ReactTestRenderer.create(<Foo prop="prop" />);
});

Expand Down Expand Up @@ -207,7 +203,9 @@ describe('ReactHooksInspectionIntegration', () => {
},
]);

updateStates();
await act(async () => {
updateStates();
});

childFiber = renderer.root.findByType(Foo)._currentFiber();
tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
Expand Down Expand Up @@ -266,7 +264,7 @@ describe('ReactHooksInspectionIntegration', () => {
]);
});

it('should inspect the current state of all stateful hooks, including useInsertionEffect', () => {
it('should inspect the current state of all stateful hooks, including useInsertionEffect', async () => {
const useInsertionEffect = React.useInsertionEffect;
const outsideRef = React.createRef();
function effect() {}
Expand All @@ -290,13 +288,9 @@ describe('ReactHooksInspectionIntegration', () => {

React.useMemo(() => state1 + state2, [state1]);

function update() {
act(() => {
setState('A');
});
act(() => {
dispatch({value: 'B'});
});
async function update() {
setState('A');
dispatch({value: 'B'});
ref.current = 'C';
}
const memoizedUpdate = React.useCallback(update, []);
Expand All @@ -307,7 +301,7 @@ describe('ReactHooksInspectionIntegration', () => {
);
}
let renderer;
act(() => {
await act(async () => {
renderer = ReactTestRenderer.create(<Foo prop="prop" />);
});

Expand Down Expand Up @@ -376,7 +370,9 @@ describe('ReactHooksInspectionIntegration', () => {
},
]);

updateStates();
await act(async () => {
updateStates();
});

childFiber = renderer.root.findByType(Foo)._currentFiber();
tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
Expand Down Expand Up @@ -967,7 +963,7 @@ describe('ReactHooksInspectionIntegration', () => {

// This test case is based on an open source bug report:
// https://github.com/facebookincubator/redux-react-hook/issues/34#issuecomment-466693787
it('should properly advance the current hook for useContext', () => {
it('should properly advance the current hook for useContext', async () => {
const MyContext = React.createContext(1);

let incrementCount;
Expand Down
Loading