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

[core] Add snapshot update feature to promise logic #5132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

davidkpiano
Copy link
Member

No description provided.

@davidkpiano davidkpiano requested a review from Andarist December 3, 2024 07:08
Copy link

changeset-bot bot commented Dec 3, 2024

⚠️ No Changeset found

Latest commit: 6a17ed6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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


expect(stuff).toEqual(
expect.arrayContaining([
expect.objectContaining({}),
Copy link
Member

Choose a reason for hiding this comment

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

it feels like a better "assertion" could be put here, this one looks suspicious - maybe we could use { status: 'active' } or smth like that?

Copy link
Member

Choose a reason for hiding this comment

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

then it would make sense to include the status in all of those assertions~

value: 'loading',
context: { progress: 0.6 }
}),
expect.objectContaining({ value: 'finished', context: undefined }),
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this test case is too big. "can emit updates" is too broad and doesn't give me much insight into what is actually expected because it reads as "it works".

For instance, I noticed that an update with just one of those fields would wipe out the other one. I was wondering how deliberate that was and if we have a test for it. It turns out we do - but it's just so buried in this item here. It's hard to tell if this was intentional or accidental. I think it was intentional and that's fine - but my point stands: a test with so many details in it isn't particularly informative/explicit about its intentions

Comment on lines +14 to +17
export interface PromiseState {
value?: StateValue;
context?: MachineContext;
}
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to add some type-level tests for usage with discriminated unions, including tests that would exercise .getSnapshot()

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
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