-
Notifications
You must be signed in to change notification settings - Fork 0
Reset polling on init
#21
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
This is most relevant to react tests since there's a single global `prefab` object, but if you `init` after starting polling, the previous polling shouldn't continue.
| if (!prefab.loader) { | ||
| throw new Error('Expected loader to be set'); | ||
| } |
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.
You may want to write these as expectations instead?
| if (!prefab.loader) { | |
| throw new Error('Expected loader to be set'); | |
| } | |
| expect(prefab.loader).not.toBeNull(); |
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.
A reasonable thing to suggest. But if I do that, I still have to guard against this being undefined or when I later call prefab.loader.context typescript complains error TS18048: 'prefab.loader' is possibly 'undefined'.
There are other ways to handle this, but IME this is the simplest way to handle it in test code.
If you have a succinct preferred approach, please do tell!
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.
Ahhhh, good ol' typescript doesn't pick up the guards from the expectations in jest yet without writing wrapper functions per this PR: microsoft/TypeScript#32695
👍 keep on trucking.
| if (prefab.pollStatus.status !== 'running') { | ||
| throw new Error('Expected pollStatus to be running'); | ||
| } |
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.
| if (prefab.pollStatus.status !== 'running') { | |
| throw new Error('Expected pollStatus to be running'); | |
| } | |
| expect(prefab.pollStatus.status).toEqual('running'); |
This is most relevant to react tests since there's a single global
prefabobject, but if youinitafter starting polling, the previouspolling shouldn't continue.