Skip to content

Commit

Permalink
Update or tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrHoroshih committed Nov 18, 2023
1 parent dc95249 commit e1cd7f0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/or/or.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ it('should be true when at least one store has truthy value', async () => {
await allSettled(iterate, { scope });
await allSettled(iterate, { scope });

expect(fn).toHaveBeenCalledTimes(2); // twice because of scope and initial
expect(fn).toHaveBeenCalledTimes(1);
expect(argumentHistory(fn)).toMatchInlineSnapshot(`
[
true,
true,
]
`);
expect(scope.getState($result)).toBe(true);
Expand All @@ -45,3 +44,20 @@ test('Returns boolean value for single store', async () => {

expect(scope.getState($andIncorrect)).toBe(true);
});

test('should be false when all stores have falsy value', async () => {
const fix = createEvent();
const $a = createStore(true).on(fix, () => false);
const $b = createStore(false);
const $c = createStore(false);

const $or = or($a, $b, $c);

const scope = fork();

expect(scope.getState($or)).toBe(true);

await allSettled(fix, { scope });

expect(scope.getState($or)).toBe(false);
});

0 comments on commit e1cd7f0

Please sign in to comment.