Skip to content

Commit

Permalink
fix up some hoc timings
Browse files Browse the repository at this point in the history
  • Loading branch information
brainkim committed Aug 6, 2021
1 parent 644f623 commit 95179a8
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/react/hoc/__tests__/queries/errors.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,36 @@ describe('[queries] errors', () => {
componentDidUpdate() {
const { props } = this;
iteration += 1;
if (iteration === 1) {
// initial loading state is done, we have data
expect(props.data!.allPeople).toEqual(
data.allPeople
);
props.setVar(2);
} else if (iteration === 2) {
// variables have changed, wee are loading again but also have data
expect(props.data!.loading).toBeTruthy();
} else if (iteration === 3) {
// the second request had an error!
expect(props.data!.error).toBeTruthy();
expect(props.data!.error!.networkError).toBeTruthy();
// // We need to set a timeout to ensure the unhandled rejection is swept up
setTimeout(() => {
expect(unhandled.length).toEqual(0);
done = true;
});
try {
if (iteration === 1) {
// initial loading state is done, we have data
expect(props.data!.allPeople).toEqual(
data.allPeople
);
props.setVar(2);
} else if (iteration === 2) {
expect(props.data!.allPeople).toEqual(
data.allPeople
);
} else if (iteration === 3) {
// variables have changed, wee are loading again but also have data
expect(props.data!.loading).toBeTruthy();
} else if (iteration === 4) {
// the second request had an error!
expect(props.data!.error).toBeTruthy();
expect(props.data!.error!.networkError).toBeTruthy();
// // We need to set a timeout to ensure the unhandled rejection is swept up
setTimeout(() => {
try {
expect(unhandled.length).toEqual(0);
} catch (err) {
reject(err);
}
done = true;
});
}
} catch (err) {
reject(err);
}
}
render() {
Expand Down

0 comments on commit 95179a8

Please sign in to comment.