u
This commit is contained in:
@@ -307,6 +307,26 @@ describe('store.article', () => {
|
||||
const limited = await store.article.getHistoryBySku(gid, art.sku, { limit: 1 });
|
||||
assert.equal(limited.length, 1);
|
||||
});
|
||||
|
||||
it('supports pagination with total and unfilteredTotal', async () => {
|
||||
const art = await createArticle(store, tenant, { name: 'PagedH0' });
|
||||
await store.article.updateBySku(gid, art.sku, { name: 'PagedH1' });
|
||||
await store.article.updateBySku(gid, art.sku, { name: 'PagedH2' });
|
||||
|
||||
const paged = await store.article.getHistoryBySku(gid, art.sku, { offset: 0, limit: 2 });
|
||||
assert.equal(typeof paged, 'object');
|
||||
assert.ok(Array.isArray(paged.history));
|
||||
assert.equal(paged.history.length, 2);
|
||||
assert.equal(paged.offset, 0);
|
||||
assert.equal(paged.limit, 2);
|
||||
assert.equal(paged.total, 3);
|
||||
assert.equal(paged.unfilteredTotal, 3);
|
||||
|
||||
const filtered = await store.article.getHistoryBySku(gid, art.sku, { offset: 0, limit: 50, search: 'PagedH2' });
|
||||
assert.equal(filtered.total, 1);
|
||||
assert.equal(filtered.unfilteredTotal, 3);
|
||||
assert.equal(filtered.history.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('listSearchIndex / listExport', () => {
|
||||
|
||||
Reference in New Issue
Block a user