@@ -79,6 +79,40 @@ test('does not archive sold inventory items', async () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('enqueues pricing refresh jobs for owned inventory items', async () => {
|
||||
const enqueued = [];
|
||||
const service = createInventoryItemService({
|
||||
productRepository: { async findById() { return null; } },
|
||||
conditionRepository: { async findById() { return null; } },
|
||||
inventoryItemRepository: {
|
||||
async listBySellerId() {
|
||||
return [{ id: 'item-1', productId: 'product-1', conditionId: 'condition-1', status: 'ACTIVE' }];
|
||||
},
|
||||
},
|
||||
pricingService: {
|
||||
async enqueueRefresh(input) {
|
||||
enqueued.push(input);
|
||||
return { id: 'job-1', status: 'PENDING' };
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const jobs = await service.refreshPricingMany({
|
||||
inventoryItemIds: ['item-1'],
|
||||
sellerId: 'seller-id',
|
||||
providerId: 'fixture-provider',
|
||||
});
|
||||
|
||||
assert.deepEqual(enqueued, [{
|
||||
sellerId: 'seller-id',
|
||||
inventoryItemId: 'item-1',
|
||||
providerId: 'fixture-provider',
|
||||
productId: 'product-1',
|
||||
conditionId: 'condition-1',
|
||||
}]);
|
||||
assert.deepEqual(jobs, [{ id: 'job-1', status: 'PENDING' }]);
|
||||
});
|
||||
|
||||
test('rejects conditions from another category', async () => {
|
||||
const service = createService({
|
||||
product: { id: 'product-id', sellerId: 'seller-id', categoryId: 'cards' },
|
||||
|
||||
Reference in New Issue
Block a user