From 4aba164c7892e8023a616914cb6f4d973856d499 Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 25 May 2026 17:18:31 +0500 Subject: [PATCH] test: add cart-notifications store tests --- .../__tests__/cart-notifications.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 client/src/shared/model/__tests__/cart-notifications.test.ts 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) + }) +})