From 95179a8c571664baa706d8b92642b436d1034578 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Fri, 6 Aug 2021 15:44:36 -0400 Subject: [PATCH] fix up some hoc timings --- .../hoc/__tests__/queries/errors.test.tsx | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/react/hoc/__tests__/queries/errors.test.tsx b/src/react/hoc/__tests__/queries/errors.test.tsx index df3664c4747..a2a16e49f6f 100644 --- a/src/react/hoc/__tests__/queries/errors.test.tsx +++ b/src/react/hoc/__tests__/queries/errors.test.tsx @@ -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() {