-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Viktor Pasynok
committed
Nov 4, 2024
1 parent
67bf5cc
commit 410027a
Showing
3 changed files
with
97 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { allSettled, createEvent, createStore, fork, sample } from 'effector'; | ||
import { createContainer } from '../../createContainer'; | ||
import { compose } from '../index'; | ||
|
||
test('up.clearNodes | all containers resolved and API is available to use', async () => { | ||
const scope = fork(); | ||
const trigger = createEvent<number>(); | ||
const $some = createStore<number | null>(null); | ||
|
||
const a = createContainer({ | ||
id: 'a', | ||
start: () => ({ | ||
api: { | ||
multiply: (x: number) => x * 2, | ||
}, | ||
}), | ||
}); | ||
const b = createContainer({ | ||
id: 'b', | ||
dependsOn: [a], | ||
start: (d) => { | ||
sample({ | ||
clock: trigger, | ||
fn: d.a.multiply, | ||
target: $some, | ||
}); | ||
|
||
return { api: null }; | ||
}, | ||
}); | ||
|
||
await compose.up([a, b]); | ||
|
||
await allSettled(trigger, { scope, params: 1 }); | ||
expect(scope.getState($some)).toBe(2); | ||
|
||
await allSettled(trigger, { scope, params: 10 }); | ||
expect(scope.getState($some)).toBe(20); | ||
}); |
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
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