diff --git a/client/src/shared/model/__tests__/cart-notifications.test.ts b/client/src/shared/model/__tests__/cart-notifications.test.ts new file mode 100644 index 0000000..1c8f1c9 --- /dev/null +++ b/client/src/shared/model/__tests__/cart-notifications.test.ts @@ -0,0 +1,23 @@ +import { allSettled, fork } from 'effector' +import { describe, it, expect } from 'vitest' +import { $cartSnackOpen, cartAdded, cartDismissed } from '../cart-notifications' + +describe('cart-notifications store', () => { + it('opens on cartAdded', async () => { + const scope = fork() + await allSettled(cartAdded, { scope }) + expect(scope.getState($cartSnackOpen)).toBe(true) + }) + + it('closes on cartDismissed', async () => { + const scope = fork() + await allSettled(cartAdded, { scope }) + await allSettled(cartDismissed, { scope }) + expect(scope.getState($cartSnackOpen)).toBe(false) + }) + + it('starts closed by default', () => { + const scope = fork() + expect(scope.getState($cartSnackOpen)).toBe(false) + }) +})