import assert from 'node:assert/strict'; import test from 'node:test'; import { createProductService } from '../../src/modules/products/services/product-service.js'; test('creates seller-scoped slugs and increments duplicate names', async () => { const createdProducts = []; const productService = createProductService({ productRepository: { async create(product) { createdProducts.push(product); return product; }, async findBySellerIdAndSlug(sellerId, slug) { return ( createdProducts.find( (product) => product.sellerId === sellerId && product.slug === slug, ) ?? null ); }, }, }); const input = { name: 'Pikachu Plush', categoryId: 'category-id', sellerId: 'seller-id', }; await productService.create(input); const secondProduct = await productService.create(input); assert.equal(secondProduct.slug, 'pikachu-plush-2'); });