Skip to content

Commit

Permalink
removed __isWithinUnmatchedTypeRefinement in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
morrys committed Oct 21, 2023
1 parent 2d4cfcc commit a615ad4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 68 deletions.
27 changes: 6 additions & 21 deletions __tests__/ReactRelayQueryRenderer-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ describe('ReactRelayQueryRenderer', () => {
id: '4',
name: 'Zuck',
username: 'Zuck',
__isWithinUnmatchedTypeRefinement: false,

__id: '4',
__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand All @@ -309,7 +309,7 @@ describe('ReactRelayQueryRenderer', () => {
id: '4',
name: 'Zuck',
username: 'Zuck',
__isWithinUnmatchedTypeRefinement: false,

__id: '4',
__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('ReactRelayQueryRenderer', () => {
id: '4',
name: 'Zuck',
username: undefined,
__isWithinUnmatchedTypeRefinement: false,

__id: '4',
__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand All @@ -377,7 +377,7 @@ describe('ReactRelayQueryRenderer', () => {
id: '4',
name: 'Zuck',
username: 'Zuck',
__isWithinUnmatchedTypeRefinement: false,

__id: '4',
__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -431,7 +431,7 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,
__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -479,7 +479,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -532,7 +531,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -576,7 +574,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -706,7 +703,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand All @@ -732,7 +728,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -800,7 +795,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand All @@ -826,7 +820,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -879,7 +872,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -939,7 +931,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '6',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -1011,7 +1002,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -1048,7 +1038,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -1534,7 +1523,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -1588,7 +1576,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand All @@ -1605,7 +1592,6 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
Expand Down Expand Up @@ -1658,7 +1644,7 @@ describe('ReactRelayQueryRenderer', () => {
data: {
node: {
id: '4',
__isWithinUnmatchedTypeRefinement: false,

__fragments: {
ReactRelayQueryRendererTestFragment: {},
},
Expand Down Expand Up @@ -2280,7 +2266,6 @@ describe('ReactRelayQueryRenderer', () => {

__fragmentOwner: owner.request,
__id: '4',
__isWithinUnmatchedTypeRefinement: false,
},
},
retry: expect.any(Function),
Expand Down
24 changes: 4 additions & 20 deletions __tests__/useFragment-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,8 @@
import * as React from 'react';
import { useMemo, useState } from 'react';
import * as TestRenderer from 'react-test-renderer';
import {
useFragment as useFragmentNodeOriginal,
useFragmentSubscription,
ReactRelayContext,
} from '../src';
import {
FRAGMENT_OWNER_KEY,
FRAGMENTS_KEY,
ID_KEY,
createOperationDescriptor,
graphql,
} from 'relay-runtime';
import { useFragment as useFragmentNodeOriginal, useFragmentSubscription, ReactRelayContext } from '../src';
import { FRAGMENT_OWNER_KEY, FRAGMENTS_KEY, ID_KEY, createOperationDescriptor, graphql } from 'relay-runtime';

/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down Expand Up @@ -57,10 +47,7 @@ const {
function assertYieldsWereCleared(_scheduler) {
const actualYields = _scheduler.unstable_clearYields();
if (actualYields.length !== 0) {
throw new Error(
'Log of yielded values is not empty. ' +
'Call expect(Scheduler).toHaveYielded(...) first.',
);
throw new Error('Log of yielded values is not empty. ' + 'Call expect(Scheduler).toHaveYielded(...) first.');
}
}

Expand Down Expand Up @@ -147,7 +134,6 @@ function createFragmentRef(id, owner, __isWithinUnmatchedTypeRefinement = false)
useFragmentTestNestedUserFragment: {},
},
[FRAGMENT_OWNER_KEY]: owner.request,
__isWithinUnmatchedTypeRefinement,
};
}

Expand Down Expand Up @@ -305,9 +291,7 @@ beforeEach(() => {

setEnvironment = _setEnv;

return (
<ReactRelayContext.Provider value={relayContext}>{children}</ReactRelayContext.Provider>
);
return <ReactRelayContext.Provider value={relayContext}>{children}</ReactRelayContext.Provider>;
};

renderSingularFragment = (args) => {
Expand Down
35 changes: 10 additions & 25 deletions __tests__/useFragmentNode-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ jest.doMock('relay-runtime', () => {
},
};
});
jest.spyOn(
require('relay-runtime').__internal,
'getPromiseForActiveRequest',
).mockImplementationOnce(() => Promise.resolve());
jest.spyOn(require('relay-runtime').__internal, 'getPromiseForActiveRequest').mockImplementationOnce(() =>
Promise.resolve(),
);

import * as React from 'react';
import { useMemo, useRef, useState } from 'react';
Expand All @@ -71,10 +70,7 @@ const warning = require('fbjs/lib/warning');
function assertYieldsWereCleared(_scheduler) {
const actualYields = (_scheduler as any).unstable_clearYields();
if (actualYields.length !== 0) {
throw new Error(
'Log of yielded values is not empty. ' +
'Call expect(Scheduler).toHaveYielded(...) first.',
);
throw new Error('Log of yielded values is not empty. ' + 'Call expect(Scheduler).toHaveYielded(...) first.');
}
}

Expand Down Expand Up @@ -149,7 +145,6 @@ function createFragmentRef(id, owner) {
useFragmentNodeTestNestedUserFragment: {},
},
[FRAGMENT_OWNER_KEY]: owner.request,
__isWithinUnmatchedTypeRefinement: false,
};
}

Expand Down Expand Up @@ -254,7 +249,6 @@ beforeEach(() => {
useFragmentNodeTestUserFragment: {},
},
[FRAGMENT_OWNER_KEY]: owner.request,
__isWithinUnmatchedTypeRefinement: false,
};
/* eslint-enable indent */
setSingularOwner = _setOwner;
Expand All @@ -276,7 +270,6 @@ beforeEach(() => {
useFragmentNodeTestUsersFragment: {},
},
[FRAGMENT_OWNER_KEY]: owner.request,
__isWithinUnmatchedTypeRefinement: false,
}));
/* eslint-enable indent */
const [usersData] = useFragmentNode(gqlPluralFragment, usersRef);
Expand All @@ -289,9 +282,7 @@ beforeEach(() => {

setEnvironment = _setEnv;

return (
<ReactRelayContext.Provider value={relayContext}>{children}</ReactRelayContext.Provider>
);
return <ReactRelayContext.Provider value={relayContext}>{children}</ReactRelayContext.Provider>;
};

renderSingularFragment = (args?: { isConcurrent?: boolean; owner?: any; userRef?: any }) => {
Expand All @@ -303,8 +294,7 @@ beforeEach(() => {
</ContextProvider>
</React.Suspense>,
// any[prop-missing] - error revealed when flow-typing ReactTestRenderer
{ unstable_isConcurrent: isConcurrent,
unstable_concurrentUpdatesByDefault: true, },
{ unstable_isConcurrent: isConcurrent, unstable_concurrentUpdatesByDefault: true },
);
};

Expand All @@ -317,8 +307,7 @@ beforeEach(() => {
</ContextProvider>
</React.Suspense>,
// any[prop-missing] - error revealed when flow-typing ReactTestRenderer
{ unstable_isConcurrent: isConcurrent,
unstable_concurrentUpdatesByDefault: true, },
{ unstable_isConcurrent: isConcurrent, unstable_concurrentUpdatesByDefault: true },
);
};
});
Expand Down Expand Up @@ -1110,9 +1099,7 @@ it('should warn if fragment reference is non-null but read-out data is null', ()
// any[prop-missing]
const [, warningMessage] = warning.mock.calls[1];
expect(
warningMessage.startsWith(
'Relay: Expected to have been able to read non-null data for fragment `%s`',
),
warningMessage.startsWith('Relay: Expected to have been able to read non-null data for fragment `%s`'),
).toEqual(true);
// any[prop-missing]
warning.mockClear();
Expand Down Expand Up @@ -1148,9 +1135,7 @@ it('should warn if plural fragment reference is non-null but read-out data is nu
// any[prop-missing]
const [, warningMessage] = warning.mock.calls[1];
expect(
warningMessage.startsWith(
'Relay: Expected to have been able to read non-null data for fragment `%s`',
),
warningMessage.startsWith('Relay: Expected to have been able to read non-null data for fragment `%s`'),
).toEqual(true);
// any[prop-missing]
warning.mockClear();
Expand Down Expand Up @@ -1313,8 +1298,8 @@ it('should subscribe for updates to plural fragments even if there is missing da
name: 'Mark',
},
],
});
});
})

// Assert render output with updated data
assertFragmentResults([
Expand Down
1 change: 0 additions & 1 deletion __tests__/usePaginationFragment-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ describe('usePaginationFragment', () => {
usePaginationFragmentTestNestedUserFragment: {},
},
[FRAGMENT_OWNER_KEY]: owner.request,
__isWithinUnmatchedTypeRefinement: false,
};
}

Expand Down
1 change: 0 additions & 1 deletion __tests__/useRefetchableFragment-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ describe('useRefetchableFragmentNode', () => {
[fragmentName]: {},
},
[FRAGMENT_OWNER_KEY]: owner.request,
__isWithinUnmatchedTypeRefinement,
};
}

Expand Down

0 comments on commit a615ad4

Please sign in to comment.