INNER CODE UNIT · TypeScript

mockLink

apollographql/apollo-link · packages/apollo-link-context/src/__tests__/index.ts:21

  const mockLink = new ApolloLink(operation => {
    expect(operation.getContext().dynamicallySet).toBe(true);
    return Observable.of({ data });
  });

  const link = withContext.concat(mockLink);

  execute(link, { query }).subscribe(result => {
    expect(result.data).toEqual(data);
    done();
  });
});

it('can be used to set the context with a function returning a promise', done => {
  const withContext = setContext(() =>
    Promise.resolve({ dynamicallySet: true }),
  );

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…