From e7fc323b44a745e93fd9f241230bd5ac05caa400 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Fri, 6 Aug 2021 16:27:31 -0400 Subject: [PATCH] TEMP COMMIT IF YOU MERGE THIS YOU WILL DIE IN 7 DAYS --- .../hoc/__tests__/queries/loading.test.tsx | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/src/react/hoc/__tests__/queries/loading.test.tsx b/src/react/hoc/__tests__/queries/loading.test.tsx index 9c0bab58731..59a50935f39 100644 --- a/src/react/hoc/__tests__/queries/loading.test.tsx +++ b/src/react/hoc/__tests__/queries/loading.test.tsx @@ -182,17 +182,21 @@ describe('[queries] loading', () => { class extends React.Component> { componentDidUpdate(prevProps: ChildProps) { const { data } = this.props; - // variables changed, new query is loading, but old data is still there - if (count === 1) { - if (data!.loading) { - expect(data!.networkStatus).toBe(2); - expect(data!.allPeople).toBeUndefined(); - } else { - expect(prevProps.data!.loading).toBe(true); - expect(data!.networkStatus).toBe(7); - expect(data!.allPeople).toEqual(data2.allPeople); - done = true; + try { + // variables changed, new query is loading, but old data is still there + if (count === 1) { + if (data!.loading) { + expect(data!.networkStatus).toBe(2); + expect(data!.allPeople).toBeUndefined(); + } else { + expect(prevProps.data!.loading).toBe(true); + expect(data!.networkStatus).toBe(7); + expect(data!.allPeople).toEqual(data2.allPeople); + done = true; + } } + } catch (err) { + reject(err); } } render() { @@ -592,25 +596,30 @@ describe('[queries] loading', () => { })( class extends React.Component> { render() { - if (count === 0) { - expect(this.props.data!.loading).toBeTruthy(); // has initial data - } + try { + if (count === 0) { + expect(this.props.data!.loading).toBeTruthy(); // has initial data + } - if (count === 1) { - expect(this.props.data!.loading).toBeFalsy(); - setTimeout(() => { - this.props.setFirst(2); - }); - } + if (count === 1) { + expect(this.props.data!.loading).toBeFalsy(); + setTimeout(() => { + this.props.setFirst(2); + }); + } - if (count === 2) { - expect(this.props.data!.loading).toBeTruthy(); // on variables change - } + if (count === 2) { + expect(this.props.data!.loading).toBeTruthy(); // on variables change + } - if (count === 3) { - // new data after fetch - expect(this.props.data!.loading).toBeFalsy(); + if (count === 3) { + // new data after fetch + expect(this.props.data!.loading).toBeFalsy(); + } + } catch (err) { + reject(err); } + count++; return null; @@ -706,27 +715,32 @@ describe('[queries] loading', () => { class extends React.Component> { render() { const { props } = this; - if (count === 0) { - expect(props.data!.loading).toBeTruthy(); - } - - if (count === 1) { - expect(props.data!.loading).toBeFalsy(); // has initial data - expect(props.data!.allPeople).toEqual(data.allPeople); - setTimeout(() => { - this.props.setFirst(2); - }); + try { + if (count === 0) { + expect(props.data!.loading).toBeTruthy(); + } + + if (count === 1) { + expect(props.data!.loading).toBeFalsy(); // has initial data + expect(props.data!.allPeople).toEqual(data.allPeople); + setTimeout(() => { + this.props.setFirst(2); + }); + } + + if (count === 2) { + expect(props.data!.loading).toBeTruthy(); // on variables change + } + + if (count === 3) { + // new data after fetch + expect(props.data!.loading).toBeFalsy(); + expect(props.data!.allPeople).toEqual(data.allPeople); + } + } catch (err) { + reject(err); } - if (count === 2) { - expect(props.data!.loading).toBeTruthy(); // on variables change - } - - if (count === 3) { - // new data after fetch - expect(props.data!.loading).toBeFalsy(); - expect(props.data!.allPeople).toEqual(data.allPeople); - } count++; return null; }