All checks were successful
continuous-integration/drone/push Build is passing
26 lines
758 B
TypeScript
26 lines
758 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { buildListQuery } from '../../src/api/query';
|
|
|
|
describe('buildListQuery', () => {
|
|
it('builds query with trimmed search and explicit sort', () => {
|
|
const result = buildListQuery({
|
|
q: ' jane ',
|
|
page: 3,
|
|
pageSize: 20,
|
|
sort: ' createdAt ',
|
|
defaultSort: '-createdAt',
|
|
});
|
|
|
|
expect(result).toBe('q=jane&page=3&pageSize=20&sort=createdAt');
|
|
});
|
|
|
|
it('falls back to defaults when query is blank and sort missing', () => {
|
|
const result = buildListQuery({
|
|
q: ' ',
|
|
defaultSort: '-createdAt',
|
|
});
|
|
|
|
expect(result).toBe('page=1&pageSize=10&sort=-createdAt');
|
|
});
|
|
});
|