8000 Add AggregateError to .any() in supported environments by JoschuaSchneider · Pull Request #25 · fluffynuts/synchronous-promise · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add AggregateError to .any() in supported environments #25

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

Conversation

JoschuaSchneider
Copy link
Contributor

This adds the AggregateError spec to the SynchronousPromise.any method. (Promise.any)

If window and window.AggregateError are defined, the method rejects with an instance of AggregateError.

I disabled JSHint for both of the blocks to allow the undefined window variable to be safely used after the checks.

The tests define a simple mock for the error and check if that implementation was used correctly.

This closes #24

@JoschuaSchneider
Copy link
Contributor Author

I missed some semicolons in the tests, I'll fix those in a second

index.spec.js Outdated
@@ -842,6 +842,43 @@ describe("synchronous-promise", function () {
expect(capturedError).property("errors").to.contain("123");
});

it("should reject with AggregateError if supported", function () {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: suggest putting this test in its own describe block and having the mocked AggregateError set up in a beforeEach and torn down in an afterEach -- covers the situation where the test, for some reason, fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give that a go, the only tiny problem I see is that this would never test the code without the AggregateError available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, if I nest the beforeEach in the describe it is scoped to that test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call the test "static any (browsers with AggregateError)", do you have a better name for that?

@JoschuaSchneider
Copy link
Contributor Author

I moved the test into a nested describe and put the mocking into hooks.

I also split up the test to make it more concice and descriptive, as the two cases affect different parts of the code.

@fluffynuts
Copy link
Owner

My only request is to refactor out a function for the repeated logic of generating the correct Error type. Shouldn't take long. Please ping me when you've done so.

Copy link
Owner
@fluffynuts fluffynuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for your contribution!

@fluffynuts fluffynuts merged commit 869e926 into fluffynuts:master Oct 8, 2020
fluffynuts added a commit that referenced this pull request Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SynchronousPromise.any should reject with AggregateError object if supported
2 participants
0