Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Added a query with a nested container.
Browse files Browse the repository at this point in the history
Again for #250
  • Loading branch information
tmeasday committed Oct 17, 2016
1 parent 39e950e commit 6512735
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/react-web/server/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => (
<div>{data.loading ? 'loading' : data.currentUser.firstName}</div>
));

const Page = () => (<div><span>Hi</span><div><WrappedElement /></div></div>);

const app = (<ApolloProvider client={apolloClient}><Page/></ApolloProvider>);

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' } };
Expand Down

0 comments on commit 6512735

Please sign in to comment.