From 15c488e9d981cc721f4f49cf997745a08b01aa7f Mon Sep 17 00:00:00 2001 From: alessia Date: Wed, 15 Mar 2023 14:15:53 -0400 Subject: [PATCH] chore: uncomment subscriptions HOC test to run against React 18 --- config/jest.config.js | 3 +- .../subscriptions/subscriptions.test.tsx | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/config/jest.config.js b/config/jest.config.js index e8aa70fba4e..bc198b73271 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -30,7 +30,7 @@ const react18TestFileIgnoreList = [ // to avoid running them twice with both react versions // since they do not import react ignoreTSFiles, - // failing hoc tests (8) + // failing hoc tests (7) 'src/react/hoc/__tests__/mutations/queries.test.tsx', 'src/react/hoc/__tests__/mutations/recycled-queries.test.tsx', 'src/react/hoc/__tests__/queries/errors.test.tsx', @@ -38,7 +38,6 @@ const react18TestFileIgnoreList = [ 'src/react/hoc/__tests__/queries/loading.test.tsx', 'src/react/hoc/__tests__/queries/observableQuery.test.tsx', 'src/react/hoc/__tests__/queries/skip.test.tsx', - 'src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx', // failing components tests (1) 'src/react/components/__tests__/client/Query.test.tsx', ]; diff --git a/src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx b/src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx index 8c54efe243b..d3c59d582ac 100644 --- a/src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx +++ b/src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx @@ -11,6 +11,8 @@ import { itAsync, MockSubscriptionLink } from '../../../../testing'; import { graphql } from '../../graphql'; import { ChildProps } from '../../types'; +const IS_REACT_18 = React.version.startsWith("18"); + describe('subscriptions', () => { let error: typeof console.error; @@ -298,20 +300,30 @@ describe('subscriptions', () => { expect(loading).toBeFalsy(); if (count === 0) expect(user).toEqual(results[0].result.data.user); - if (count === 1) - expect(user).toEqual(results[0].result.data.user); + if (count === 1) { + if (IS_REACT_18) { + expect(user).toEqual(results[1].result.data.user); + } else { + expect(user).toEqual(results[0].result.data.user); + } + } if (count === 2) expect(user).toEqual(results[2].result.data.user); if (count === 3) expect(user).toEqual(results[2].result.data.user); - if (count === 4) - expect(user).toEqual( - results3[2].result.data.user - ); + if (count === 4) { + if (IS_REACT_18) { + expect(user).toEqual(results[2].result.data.user); + } else { + expect(user).toEqual(results3[2].result.data.user); + } + } if (count === 5) { - expect(user).toEqual( - results3[2].result.data.user - ); + if (IS_REACT_18) { + expect(user).toEqual(results3[3].result.data.user); + } else { + expect(user).toEqual(results3[2].result.data.user); + } resolve(); } } catch (e) {