Skip to content

Commit

Permalink
Convert ReactRelayRefetchContainer-WithFragmentOwnership-test to use …
Browse files Browse the repository at this point in the history
…the new compiler

Summary:
We're working on deprecating JS compiler.
One of the steps, is to remove it from our unit-tests.

This is the test from #3199

Steps:
- Remove generateAndCompile
- Wrap graphql documents with graphql tag + add unique prefix
- Run new compiler: scripts/compile-tests.sh

Reviewed By: tyao1

Differential Revision: D25875336

fbshipit-source-id: 0be387d9881a615cca47bd6a05a0249b10334d49
  • Loading branch information
alunyov authored and facebook-github-bot committed Jan 13, 2021
1 parent 2383197 commit 20051f6
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ const {
createReaderSelector,
createRequestDescriptor,
ROOT_ID,
graphql,
} = require('relay-runtime');
const {
createMockEnvironment,
generateAndCompile,
} = require('relay-test-utils-internal');
const {createMockEnvironment} = require('relay-test-utils-internal');

describe('ReactRelayRefetchContainer with fragment ownerhsip', () => {
let TestChildComponent;
Expand Down Expand Up @@ -106,35 +104,35 @@ describe('ReactRelayRefetchContainer with fragment ownerhsip', () => {
jest.resetModules();

environment = createMockEnvironment();
({UserFragment, UserFriendFragment, UserQuery} = generateAndCompile(`
query UserQuery(
UserQuery = graphql`
query ReactRelayRefetchContainerWithFragmentOwnershipTestUserQuery(
$id: ID!
$scale: Int!
) {
node(id: $id) {
...UserFragment
...ReactRelayRefetchContainerWithFragmentOwnershipTestUserFragment
}
}
fragment UserFragment on User @argumentDefinitions(
cond: {type: "Boolean!", defaultValue: true}
) {
`;
UserFragment = graphql`
fragment ReactRelayRefetchContainerWithFragmentOwnershipTestUserFragment on User
@argumentDefinitions(cond: {type: "Boolean!", defaultValue: true}) {
id
name @include(if: $cond)
profile_picture(scale: $scale) {
uri
}
...UserFriendFragment @arguments(cond: $cond)
...ReactRelayRefetchContainerWithFragmentOwnershipTestUserFriendFragment
@arguments(cond: $cond)
}
fragment UserFriendFragment on User @argumentDefinitions(
cond: {type: "Boolean!", defaultValue: true}
) {
`;
UserFriendFragment = graphql`
fragment ReactRelayRefetchContainerWithFragmentOwnershipTestUserFriendFragment on User
@argumentDefinitions(cond: {type: "Boolean!", defaultValue: true}) {
id
username @include(if: $cond)
}
`));

`;
TestChildComponent = jest.fn(() => <div />);
TestChildContainer = ReactRelayFragmentContainer.createContainer(
TestChildComponent,
Expand Down Expand Up @@ -223,7 +221,11 @@ describe('ReactRelayRefetchContainer with fragment ownerhsip', () => {
uri: 'zuck2',
},
__id: '4',
__fragments: {UserFriendFragment: {cond: true}},
__fragments: {
ReactRelayRefetchContainerWithFragmentOwnershipTestUserFriendFragment: {
cond: true,
},
},
__fragmentOwner: ownerUser1.request,
});
expect(TestChildComponent.mock.calls.length).toBe(1);
Expand Down Expand Up @@ -270,7 +272,11 @@ describe('ReactRelayRefetchContainer with fragment ownerhsip', () => {
uri: 'zuck2',
},
__id: '4',
__fragments: {UserFriendFragment: {cond: false}},
__fragments: {
ReactRelayRefetchContainerWithFragmentOwnershipTestUserFriendFragment: {
cond: false,
},
},
__fragmentOwner: expectedOwner.request,
});
expect(render.mock.calls[0][0].user.name).toBe(undefined);
Expand All @@ -291,7 +297,11 @@ describe('ReactRelayRefetchContainer with fragment ownerhsip', () => {
uri: 'zuck2',
},
__id: '4',
__fragments: {UserFriendFragment: {cond: true}},
__fragments: {
ReactRelayRefetchContainerWithFragmentOwnershipTestUserFriendFragment: {
cond: true,
},
},
__fragmentOwner: ownerUser1.request,
});
expect(TestChildComponent.mock.calls.length).toBe(1);
Expand Down Expand Up @@ -344,7 +354,11 @@ describe('ReactRelayRefetchContainer with fragment ownerhsip', () => {
uri: 'zuck2',
},
__id: '4',
__fragments: {UserFriendFragment: {cond: false}},
__fragments: {
ReactRelayRefetchContainerWithFragmentOwnershipTestUserFriendFragment: {
cond: false,
},
},
__fragmentOwner: expectedOwner.request,
});
expect(render.mock.calls[0][0].user.name).toBe(undefined);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 20051f6

Please sign in to comment.