{
+ state = { first: 1 };
+
+ componentDidMount() {
+ setTimeout(() => {
+ count++;
+ this.setState({ first: 2 });
+ }, 50);
+
+ setTimeout(() => {
+ count++;
+ this.setState({ first: 3 });
+ }, 100);
+ }
+
+ render() {
+ return ;
+ }
+ }
+
+ renderer.create();
+ });
+
it('reruns the query if it changes', (done) => {
let count = 0;
const query = gql`
diff --git a/test/react-web/server/index.test.tsx b/test/react-web/server/index.test.tsx
index 7cfa44451b..3c6a8378c7 100644
--- a/test/react-web/server/index.test.tsx
+++ b/test/react-web/server/index.test.tsx
@@ -55,6 +55,52 @@ describe('SSR', () => {
;
});
+ it('should correctly skip queries (deprecated)', () => {
+
+ 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, { options: { skip: true }})(({ data }) => (
+ {data.loading ? 'loading' : 'skipped'}
+ ));
+
+ const app = ();
+
+ return getDataFromTree(app)
+ .then(() => {
+ const markup = ReactDOM.renderToString(app);
+ expect(markup).toMatch(/skipped/);
+ })
+ ;
+ });
+
+ it('should correctly skip queries (deprecated)', () => {
+
+ 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, { skip: true })(({ data }) => (
+ {!data ? 'skipped' : 'dang'}
+ ));
+
+ const app = ();
+
+ return getDataFromTree(app)
+ .then(() => {
+ const markup = ReactDOM.renderToString(app);
+ expect(markup).toMatch(/skipped/);
+ })
+ ;
+ });
+
it('should run return the initial state for hydration', () => {
const query = gql`{ currentUser { firstName } }`;
const data = { currentUser: { firstName: 'James' } };