Skip to content

Commit

Permalink
failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Dec 23, 2024
1 parent d5fd405 commit 19b7a87
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion packages/executors/apollo-link/tests/apollo-link.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { setTimeout } from 'timers/promises';
import { parse } from 'graphql';
import { createSchema, createYoga } from 'graphql-yoga';
import { createSchema, createYoga, Repeater } from 'graphql-yoga';
import { ApolloClient, FetchResult, InMemoryCache } from '@apollo/client/core';
import { buildHTTPExecutor } from '@graphql-tools/executor-http';
import { createDeferred } from '@graphql-tools/utils';
import { testIf } from '../../../testing/utils.js';
import { ExecutorLink } from '../src/index.js';

describe('Apollo Link', () => {
const { promise: waitForPingStop, resolve: pingStop } = createDeferred<void>();
const yoga = createYoga({
logging: false,
maskedErrors: false,
Expand All @@ -21,6 +23,7 @@ describe('Apollo Link', () => {
}
type Subscription {
time: String
ping: String
}
`,
resolvers: {
Expand All @@ -40,6 +43,13 @@ describe('Apollo Link', () => {
},
resolve: str => str,
},
ping: {
subscribe: () =>
new Repeater(async (_pull, stop) => {
await stop;
pingStop();
}),
},
},
},
}),
Expand Down Expand Up @@ -121,4 +131,20 @@ describe('Apollo Link', () => {
readFile: 'Hello World',
});
});
it('should complete subscription even while waiting for events', async () => {
const observable = client.subscribe({
query: parse(/* GraphQL */ `
subscription Ping {
ping
}
`),
});
const sub = observable.subscribe({
next: () => {
// noop
},
});
globalThis.setTimeout(() => sub.unsubscribe(), 0);
await waitForPingStop;
});
});

0 comments on commit 19b7a87

Please sign in to comment.