feat: add public listing catalog boundary
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { createPublicListingService } from '../../src/modules/listings/services/public-listing-service.js';
|
||||
|
||||
test('lists visible public listings through the shared repository search boundary', async () => {
|
||||
const service = createPublicListingService({
|
||||
listingRepository: {
|
||||
async searchPublic(filters) {
|
||||
assert.deepEqual(filters, { query: '', page: 2, limit: 5 });
|
||||
return { items: [{ id: 'listing-1' }], total: 1 };
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(await service.list({ page: 2, limit: 5 }), {
|
||||
items: [{ id: 'listing-1' }],
|
||||
total: 1,
|
||||
});
|
||||
});
|
||||
|
||||
test('returns a not-found application error for a hidden public listing', async () => {
|
||||
const service = createPublicListingService({
|
||||
listingRepository: { async findPublicById() { return null; } },
|
||||
});
|
||||
|
||||
await assert.rejects(
|
||||
() => service.getById('listing-1'),
|
||||
(error) => error.code === 'LISTING_NOT_FOUND' && error.statusCode === 404,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user