Tests refactor
This commit is contained in:
parent
245520fb50
commit
99134d8556
165 changed files with 911 additions and 531 deletions
|
|
@ -1,54 +0,0 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { apiClient } from './api-client';
|
||||
import * as PricesService from './prices';
|
||||
|
||||
vi.mock('./api-client', () => ({
|
||||
apiClient: {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('prices service', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('recordPrice', async () => {
|
||||
const data = { productId: 'p1', price: 10 } as any;
|
||||
await PricesService.recordPrice('hh1', data);
|
||||
expect(apiClient.post).toHaveBeenCalledWith('/households/hh1/prices', data);
|
||||
});
|
||||
|
||||
it('recordBulkPrices', async () => {
|
||||
const data = { storeId: 's1', items: [] } as any;
|
||||
await PricesService.recordBulkPrices('hh1', data);
|
||||
expect(apiClient.post).toHaveBeenCalledWith('/households/hh1/prices/bulk', data);
|
||||
});
|
||||
|
||||
it('getPriceHistory with and without query', async () => {
|
||||
await PricesService.getPriceHistory('hh1', 'p1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/prices/history/p1');
|
||||
|
||||
await PricesService.getPriceHistory('hh1', 'p1', {
|
||||
storeId: 's1',
|
||||
startDate: '2026-05-01',
|
||||
endDate: '2026-05-10',
|
||||
cursor: 'cur',
|
||||
limit: 10,
|
||||
});
|
||||
expect(apiClient.get).toHaveBeenCalledWith(
|
||||
'/households/hh1/prices/history/p1?storeId=s1&startDate=2026-05-01&endDate=2026-05-10&cursor=cur&limit=10'
|
||||
);
|
||||
});
|
||||
|
||||
it('compareStores', async () => {
|
||||
await PricesService.compareStores('hh1', 'p1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/prices/compare/p1');
|
||||
});
|
||||
|
||||
it('getPriceAnalytics', async () => {
|
||||
await PricesService.getPriceAnalytics('hh1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/prices/analytics');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue