Created
September 23, 2021 17:22
-
-
Save AlexandrHoroshih/77c2a0c820a92bdde2a4c9d5195625da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('stuff', async () => { | |
// create new forked scope, which is completly independent | |
const scope = fork({ | |
// apply modifications like initial store values in this scope | |
values: new Map() | |
.set($myStore, "value"), // changed value in $myStore specifically for this scope | |
handlers: new Map() | |
.set(myFx, mockHandler) // changed effect handler to mock one for this scope | |
}); | |
// launching event or effect, which triggers the logic we want to test | |
// we doing it just in our forked scope | |
await allSettled(startEvent, { | |
scope, | |
params: // params of startEvent | |
}) | |
// check states of stores in this scope after all calculations ended | |
expect(scope.getState($myStore)).toEqual(...) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment