import { describe, it, expect } from 'vitest' import type { Product, Order, CartItem, OrderStatus, SizeStock } from '@shared/types' describe('shared types', () => { it('Product type enforces integer sats', () => { const product: Product = { id: 'test-1', name: 'Test Product', slug: 'test-product', description: 'A test product', priceSats: 100_000, images: ['/images/test.jpg'], sizes: [{ size: 'M', stock: 10 }], category: 'tops', isActive: true, createdAt: '2026-01-01T00:00:00Z', updatedAt: '2026-01-01T00:00:00Z', } expect(product.priceSats).toBe(100_000) expect(Number.isInteger(product.priceSats)).toBe(true) }) it('CartItem calculates correctly with integer sats', () => { const item: CartItem = { productId: 'test-1', slug: 'test-product', name: 'Test Product', size: 'M', quantity: 3, priceSats: 85_000, image: '/images/test.jpg', } const total = item.priceSats * item.quantity expect(total).toBe(255_000) expect(Number.isInteger(total)).toBe(true) }) it('OrderStatus has valid values', () => { const statuses: OrderStatus[] = ['pending', 'paid', 'confirmed', 'shipped', 'delivered', 'cancelled'] expect(statuses).toHaveLength(6) }) it('SizeStock tracks integer stock levels', () => { const sizes: SizeStock[] = [ { size: 'S', stock: 10 }, { size: 'M', stock: 0 }, ] const totalStock = sizes.reduce((sum, s) => sum + s.stock, 0) expect(totalStock).toBe(10) expect(sizes[1].stock).toBe(0) }) })