diff --git a/test/react-web/server/index.test.tsx b/test/react-web/server/index.test.tsx index a65c1bc249..41eddac900 100644 --- a/test/react-web/server/index.test.tsx +++ b/test/react-web/server/index.test.tsx @@ -54,6 +54,30 @@ describe('SSR', () => { }); }); + it('should pick up queries deep in the render tree', () => { + + const query = gql`{ currentUser { firstName } }`; + const data = { currentUser: { firstName: 'James' } }; + const networkInterface = mockNetworkInterface( + { request: { query }, result: { data }, delay: 50 } + ); + const apolloClient = new ApolloClient({ networkInterface }); + + const WrappedElement = graphql(query)(({ data }) => ( +
{data.loading ? 'loading' : data.currentUser.firstName}
+ )); + + const Page = () => (
Hi
); + + const app = (); + + return getDataFromTree(app) + .then(() => { + const markup = ReactDOM.renderToString(app); + expect(markup).toMatch(/James/); + }); + }); + it('should handle nested queries that depend on each other', () => { const idQuery = gql`{ currentUser { id } }`; const idData = { currentUser: { id: '1234' } };