Cleanup after initial plan
This commit is contained in:
parent
d2a7e652b3
commit
245520fb50
53 changed files with 6733 additions and 621 deletions
37
packages/web/src/services/nutrition-targets.test.ts
Normal file
37
packages/web/src/services/nutrition-targets.test.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { apiClient } from './api-client';
|
||||
import * as NutritionTargetsService from './nutrition-targets';
|
||||
|
||||
vi.mock('./api-client', () => ({
|
||||
apiClient: {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('nutrition-targets service', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('getActiveNutritionTarget', async () => {
|
||||
await NutritionTargetsService.getActiveNutritionTarget('hh1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/nutrition-targets');
|
||||
});
|
||||
|
||||
it('getNutritionTargetHistory', async () => {
|
||||
await NutritionTargetsService.getNutritionTargetHistory('hh1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/nutrition-targets/history');
|
||||
});
|
||||
|
||||
it('setNutritionTarget', async () => {
|
||||
const data = { calories: 2000 } as any;
|
||||
await NutritionTargetsService.setNutritionTarget('hh1', data);
|
||||
expect(apiClient.post).toHaveBeenCalledWith('/households/hh1/nutrition-targets', data);
|
||||
});
|
||||
|
||||
it('calculateTargetPreset', async () => {
|
||||
await NutritionTargetsService.calculateTargetPreset('hh1', 2500, 'gain');
|
||||
expect(apiClient.post).toHaveBeenCalledWith('/households/hh1/nutrition-targets/presets', { calories: 2500, strategy: 'gain' });
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue