Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Flow on "subscribe-test.js" #1865

Merged
merged 1 commit into from May 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/subscription/__tests__/subscribe-test.js
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
* @flow strict
*/

import { expect } from 'chai';
Expand Down Expand Up @@ -129,6 +129,7 @@ async function createSubscription(pubsub, schema = emailSchema, ast, vars) {
// `subscribe` returns Promise<AsyncIterator | ExecutionResult>
return {
sendImportantEmail,
// $FlowFixMe
subscription: await subscribe(schema, ast || defaultAST, data, null, vars),
};
}
Expand Down Expand Up @@ -163,6 +164,7 @@ describe('Subscription Initialization Phase', () => {
},
});

// $FlowFixMe
ai.return();
});

Expand Down Expand Up @@ -224,6 +226,7 @@ describe('Subscription Initialization Phase', () => {
importantEmail: {},
});

// $FlowFixMe
await subscription.next();
});

Expand Down Expand Up @@ -257,6 +260,7 @@ describe('Subscription Initialization Phase', () => {
importantEmail: {},
});

// $FlowFixMe
await subscription.next();
});

Expand Down Expand Up @@ -297,6 +301,7 @@ describe('Subscription Initialization Phase', () => {
`);

const subscription = await subscribe(testSchema, ast);
// $FlowFixMe
subscription.next(); // Ask for a result, but ignore it.

expect(didResolveImportantEmail).to.equal(true);
Expand All @@ -314,23 +319,27 @@ describe('Subscription Initialization Phase', () => {
`);

await expectPromiseToThrow(
// $DisableFlowOnNegativeTest
() => subscribe(null, document),
'Expected null to be a GraphQL schema.',
);

await expectPromiseToThrow(
// $DisableFlowOnNegativeTest
() => subscribe({ document }),
'Expected undefined to be a GraphQL schema.',
);
});

it('throws an error if document is missing', async () => {
await expectPromiseToThrow(
// $DisableFlowOnNegativeTest
() => subscribe(emailSchema, null),
'Must provide document',
);

await expectPromiseToThrow(
// $DisableFlowOnNegativeTest
() => subscribe({ schema: emailSchema }),
'Must provide document',
);
Expand Down Expand Up @@ -465,6 +474,7 @@ describe('Subscription Initialization Phase', () => {
},
};

// $FlowFixMe
const result = await subscribe(emailSchema, ast, data, null, {
priority: 'meow',
});
Expand Down Expand Up @@ -831,6 +841,7 @@ describe('Subscription Publish Phase', () => {
`),
);

// $FlowFixMe
const payload1 = await subscription.next();
expect(payload1).to.deep.equal({
done: false,
Expand Down Expand Up @@ -902,6 +913,7 @@ describe('Subscription Publish Phase', () => {
`),
);

// $FlowFixMe
const payload1 = await subscription.next();
expect(payload1).to.deep.equal({
done: false,
Expand Down