it('should not cache subscription data if a `no-cache` fetch policy is used', done => {
    const link = mockObservableLink(sub1);
    const cache = new InMemoryCache({ addTypename: false });
    const client = new ApolloClient({
      link,
      cache,
    });

    expect(cache.extract()).toEqual({});

    options.fetchPolicy = 'no-cache';
    const sub = client.subscribe(options).subscribe({
      next() {
        expect(cache.extract()).toEqual({});
        sub.unsubscribe();
        done();
      },
    });

    link.simulateResult(results[0]);
  });
Example #2
0
  it('writes defaults to the cache upon initialization', () => {
    const cache = new InMemoryCache();

    withClientState({ cache, resolvers, defaults });
    expect(cache.extract()).toMatchSnapshot();
  });