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

add dispatch unit tests and minor refactoring #602

Merged
merged 6 commits into from
Sep 26, 2022
Merged

Conversation

silesky
Copy link
Contributor

@silesky silesky commented Sep 23, 2022

There were no unit tests covering dispatch, so I needed to add some to sleep at night, (and also because it seems a fairly importanish part of core). In doing so, uncovered weird behavior -- would like clarity on it.

@changeset-bot
Copy link

changeset-bot bot commented Sep 23, 2022

🦋 Changeset detected

Latest commit: 31ccfd7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@segment/analytics-core Patch
@segment/analytics-next Patch
@segment/analytics-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@silesky silesky requested a review from chrisradek September 23, 2022 22:38
@silesky silesky requested a review from pooyaj September 23, 2022 22:40
@silesky silesky changed the title add dispatch unit tests add dispatch unit tests and minor refactoring Sep 23, 2022
@silesky silesky force-pushed the add-dispatch-tests branch 2 times, most recently from 210cbeb to 522e62c Compare September 25, 2022 20:01
})

// TODO: Inconsistent behavior? This seems like a bug.
it('should have inconsistent timeout behavior where the delay is different based on whether timeout is explicitly set to 1000 or not', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @pooyaj

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is intentional, 300ms default, but it is configurable.

Math.max((timeoutInMs ?? 300) - elapsedTime, 0),
timeoutInMs
getDelay(startTime, options.timeout), // TODO: I have no idea why this delay is based on the timeout -- so if you set a timeout of 5seconds, it will (in addition) actually delay ~5seconds before invoking.
options.timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that makes sense. So normally 300ms timeout, but let user configure the value to whatever they want?

})

// TODO: Inconsistent behavior? This seems like a bug.
it('should have inconsistent timeout behavior where the delay is different based on whether timeout is explicitly set to 1000 or not', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is intentional, 300ms default, but it is configurable.

@silesky silesky merged commit 4644afc into master Sep 26, 2022
@silesky silesky deleted the add-dispatch-tests branch September 26, 2022 22:19
@github-actions github-actions bot mentioned this pull request Sep 26, 2022
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.

2 participants