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

subscribe-test: extract subscribeWithBadFn function #3630

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Jun 7, 2022

Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both subscribe and createSourceEventStream.

This PR extracts the duplicated logic into a single common subscribeWithBadFn function.

For convenience, the common function is typed to appropriately return a Promise<ExecutionResult> rather than a Promise<ExecutionResult | AsyncGenerator<...>>). Because the subscribeFn is expected to be "bad," an AsyncGenerator should never be returned. If a valid subscribeFn is mistakenly passed, an assertion failure is triggered.

extracted from #3620

Two test groups use essentially the same logic to set up a subscription with an improper subscribeFn, testing both `subscribe` and `createSourceEventStream`.

This PR extracts the duplicated logic into a single common `subscribeWithBadFn` function.

For convenience, the common function is typed to appropriately return a `Promise<ExecutionResult>` rather than a `Promise<ExecutionResult | AsyncGenerator<...>>`). Because the `subscribeFn` is expected to be "bad," an `AsyncGenerator` should never be returned. If a valid `subscribeFn` is mistakenly passed, an assertion failure is triggered.

extracted from graphql#3620
@netlify
Copy link

netlify bot commented Jun 7, 2022

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit 75d3061
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/629f0687c0daa90008167946
😎 Deploy Preview https://deploy-preview-3630--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Jun 7, 2022

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

@yaacovCR yaacovCR requested a review from a team June 7, 2022 10:01
@yaacovCR yaacovCR added the PR: polish 💅 PR doesn't change public API or any observed behaviour label Jun 7, 2022
@IvanGoncharov IvanGoncharov merged commit 2deb272 into graphql:main Jun 8, 2022
@yaacovCR yaacovCR deleted the extract branch June 10, 2022 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: polish 💅 PR doesn't change public API or any observed behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants