test(UnifiedFontStore): add filter setter tests
This commit is contained in:
@@ -280,3 +280,54 @@ describe('pagination navigation', () => {
|
|||||||
expect(store.params.limit).toBe(25);
|
expect(store.params.limit).toBe(25);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('filter setters', () => {
|
||||||
|
let store: UnifiedFontStore;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
store = new UnifiedFontStore({ limit: 10 });
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
store.destroy();
|
||||||
|
queryClient.clear();
|
||||||
|
vi.resetAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setProviders() updates the providers param', () => {
|
||||||
|
store.setProviders(['google']);
|
||||||
|
|
||||||
|
expect(store.params.providers).toEqual(['google']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setCategories() updates the categories param', () => {
|
||||||
|
store.setCategories(['serif']);
|
||||||
|
|
||||||
|
expect(store.params.categories).toEqual(['serif']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setSubsets() updates the subsets param', () => {
|
||||||
|
store.setSubsets(['cyrillic']);
|
||||||
|
|
||||||
|
expect(store.params.subsets).toEqual(['cyrillic']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setSearch() sets the q param', () => {
|
||||||
|
store.setSearch('roboto');
|
||||||
|
|
||||||
|
expect(store.params.q).toBe('roboto');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setSearch() with empty string sets q to undefined', () => {
|
||||||
|
store.setSearch('roboto');
|
||||||
|
store.setSearch('');
|
||||||
|
|
||||||
|
expect(store.params.q).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setSort() updates the sort param', () => {
|
||||||
|
store.setSort('popularity');
|
||||||
|
|
||||||
|
expect(store.params.sort).toBe('popularity');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user