Mix calculator
This commit is contained in:
@@ -4,6 +4,9 @@ const apiMocks = vi.hoisted(() => ({
|
||||
rawMaterials: vi.fn(),
|
||||
mixes: vi.fn(),
|
||||
mix: vi.fn(),
|
||||
mixCalculatorOptions: vi.fn(),
|
||||
mixCalculatorSessions: vi.fn(),
|
||||
mixCalculatorSession: vi.fn(),
|
||||
products: vi.fn(),
|
||||
productCosts: vi.fn(),
|
||||
scenarios: vi.fn(),
|
||||
@@ -30,6 +33,10 @@ import { load as adminLoad } from './admin/+page';
|
||||
import { load as mixesLoad } from './mixes/+page';
|
||||
import { load as mixNewLoad } from './mixes/new/+page';
|
||||
import { load as mixDetailLoad } from './mixes/[id]/+page';
|
||||
import { load as mixCalculatorLoad } from './mix-calculator/+page';
|
||||
import { load as mixCalculatorNewLoad } from './mix-calculator/new/+page';
|
||||
import { load as mixCalculatorDetailLoad } from './mix-calculator/[id]/+page';
|
||||
import { load as mixCalculatorPrintLoad } from './mix-calculator/[id]/print/+page';
|
||||
import { load as productsLoad } from './products/+page';
|
||||
import { load as rawMaterialsLoad } from './raw-materials/+page';
|
||||
import { load as scenariosLoad } from './scenarios/+page';
|
||||
@@ -47,6 +54,9 @@ describe('route loaders use the SvelteKit fetch argument', () => {
|
||||
apiMocks.rawMaterials.mockResolvedValue([{ id: 1 }]);
|
||||
apiMocks.mixes.mockResolvedValue([{ id: 2 }]);
|
||||
apiMocks.mix.mockResolvedValue({ id: 42 });
|
||||
apiMocks.mixCalculatorOptions.mockResolvedValue({ clients: ['Hunter Premium Produce'], products: [{ product_id: 1 }] });
|
||||
apiMocks.mixCalculatorSessions.mockResolvedValue([{ id: 11 }]);
|
||||
apiMocks.mixCalculatorSession.mockResolvedValue({ id: 12 });
|
||||
apiMocks.products.mockResolvedValue([{ id: 3 }]);
|
||||
apiMocks.productCosts.mockResolvedValue([{ id: 4 }]);
|
||||
apiMocks.scenarios.mockResolvedValue([{ id: 5 }]);
|
||||
@@ -108,6 +118,31 @@ describe('route loaders use the SvelteKit fetch argument', () => {
|
||||
expect(apiMocks.productCosts).toHaveBeenCalledWith(fetcher);
|
||||
});
|
||||
|
||||
it('passes fetch through the mix calculator history loader', async () => {
|
||||
await mixCalculatorLoad({ fetch: fetcher } as never);
|
||||
|
||||
expect(apiMocks.mixCalculatorSessions).toHaveBeenCalledWith(fetcher);
|
||||
});
|
||||
|
||||
it('passes fetch through the new mix calculator loader', async () => {
|
||||
await mixCalculatorNewLoad({ fetch: fetcher } as never);
|
||||
|
||||
expect(apiMocks.mixCalculatorOptions).toHaveBeenCalledWith(fetcher);
|
||||
});
|
||||
|
||||
it('passes fetch through the mix calculator detail loader', async () => {
|
||||
await mixCalculatorDetailLoad({ params: { id: '12' }, fetch: fetcher } as never);
|
||||
|
||||
expect(apiMocks.mixCalculatorSession).toHaveBeenCalledWith(12, fetcher);
|
||||
expect(apiMocks.mixCalculatorOptions).toHaveBeenCalledWith(fetcher);
|
||||
});
|
||||
|
||||
it('passes fetch through the mix calculator print loader', async () => {
|
||||
await mixCalculatorPrintLoad({ params: { id: '12' }, fetch: fetcher } as never);
|
||||
|
||||
expect(apiMocks.mixCalculatorSession).toHaveBeenCalledWith(12, fetcher);
|
||||
});
|
||||
|
||||
it('passes fetch through the scenarios loader', async () => {
|
||||
await scenariosLoad({ fetch: fetcher } as never);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user