35 lines
1019 B
JavaScript
35 lines
1019 B
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { buildApp } from '../../src/app/build-app.js';
|
|
|
|
test('returns public search results with pagination metadata', async (testContext) => {
|
|
const app = buildApp({
|
|
searchService: {
|
|
async searchPublic(filters) {
|
|
assert.equal(filters.page, 2);
|
|
assert.equal(filters.limit, 5);
|
|
assert.equal(filters.includeSold, true);
|
|
return {
|
|
items: [{ id: 'listing-1', status: 'CLOSED' }],
|
|
pagination: { page: 2, limit: 5, total: 6, totalPages: 2 },
|
|
};
|
|
},
|
|
},
|
|
});
|
|
testContext.after(() => app.close());
|
|
|
|
const response = await app.inject({
|
|
method: 'GET',
|
|
url: '/api/v1/public/search?query=charizard&page=2&limit=5&includeSold=true',
|
|
});
|
|
|
|
assert.equal(response.statusCode, 200);
|
|
assert.deepEqual(response.json().data.pagination, {
|
|
page: 2,
|
|
limit: 5,
|
|
total: 6,
|
|
totalPages: 2,
|
|
});
|
|
assert.equal(response.json().data.items[0].id, 'listing-1');
|
|
}); |