Files
2026-09-10 00:51:05 -04:00

30 lines
835 B
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createProduct } from '../../src/modules/products/domain/product.js';
test('creates a product with required product identity fields', () => {
const product = createProduct({
name: ' Charizard ex ',
categoryId: 'category-id',
sellerId: 'seller-id',
});
assert.deepEqual(product, {
name: 'Charizard ex',
categoryId: 'category-id',
sellerId: 'seller-id',
tags: [],
});
});
test('rejects a product without a name or category', () => {
assert.throws(
() => createProduct({ name: ' ', categoryId: 'category-id', sellerId: 'seller-id' }),
/Product name is required/,
);
assert.throws(
() => createProduct({ name: 'Pikachu', categoryId: '', sellerId: 'seller-id' }),
/Category ID is required/,
);
});