-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
expect(stuff).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({}), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 }), |
There was a problem hiding this comment.
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
export interface PromiseState { | ||
value?: StateValue; | ||
context?: MachineContext; | ||
} |
There was a problem hiding this comment.
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 <[email protected]>
No description provided.