This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { createProviderMappingService } from '../../src/modules/pricing/services/provider-mapping-service.js';
|
||||
|
||||
test('creates and disables seller-owned provider mappings', async () => {
|
||||
const calls = [];
|
||||
const service = createProviderMappingService({
|
||||
providerMappingRepository: {
|
||||
async createForSeller(input, sellerId) { calls.push(['create', input, sellerId]); return { status: 'CREATED', mapping: { id: 'mapping-1', ...input } }; },
|
||||
async listForSeller() { return [{ id: 'mapping-1', status: 'ACTIVE' }]; },
|
||||
async disableForSeller() { return { status: 'DISABLED', mapping: { id: 'mapping-1', status: 'DISABLED' } }; },
|
||||
},
|
||||
});
|
||||
|
||||
const created = await service.create({ sellerId: 'seller-1', productId: 'product-1', providerId: 'fixture', mappingType: 'PRODUCT', externalIdentifier: 'ext-1' });
|
||||
assert.equal(created.id, 'mapping-1');
|
||||
assert.equal(calls[0][2], 'seller-1');
|
||||
assert.equal((await service.list({ sellerId: 'seller-1', productId: 'product-1' })).length, 1);
|
||||
assert.equal((await service.disable({ sellerId: 'seller-1', id: 'mapping-1' })).status, 'DISABLED');
|
||||
});
|
||||
Reference in New Issue
Block a user