Fix type issues in tests

This commit is contained in:
beatz174-bit committed 2025-12-01 22:00:27 +10:00
1 parent 5edc2057be
commit 6917d944fe
2 files changed
+8 -4

No files matched your search

@@ -57,7 +57,7 @@ describe('AddProductDialog', () => {
}); });
it('applies initialBarcode and triggers lookup', async () => { it('applies initialBarcode and triggers lookup', async () => {
fetchProductSpy.mockResolvedValue({ name: 'From OFF' }); fetchProductSpy.mockResolvedValue({ name: 'From OFF', source: 'openfoodfacts' });
render( render(
<AddProductDialog <AddProductDialog
@@ -2,6 +2,7 @@ import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi, beforeEach } from 'vitest'; import { describe, expect, it, vi, beforeEach } from 'vitest';
import { ProductRow } from '../ProductRow'; import { ProductRow } from '../ProductRow';
import type { Product } from '../../models/Product';
import { makeNamedError } from '../../test/makeNamedError'; import { makeNamedError } from '../../test/makeNamedError';
vi.mock('../BarcodeScannerView', () => ({ vi.mock('../BarcodeScannerView', () => ({
@@ -18,20 +19,23 @@ const categoriesById = new Map([
['cat-2', 'Drinks'], ['cat-2', 'Drinks'],
]); ]);
const baseProduct = { const baseProduct: Product = {
id: 'p1', id: 'p1',
name: 'Product One', name: 'Product One',
category: 'cat-1', category: 'cat-1',
unit_type: 'unit', unit_type: 'unit',
bulk_name: 'carton', bulk_name: 'carton',
barcode: undefined,
archived: false, archived: false,
created_at: 0, created_at: 0,
updated_at: 0, updated_at: 0,
}; };
describe('ProductRow error handling', () => { describe('ProductRow error handling', () => {
let onSave: ReturnType<typeof vi.fn>; let onSave: ReturnType<
let onDelete: ReturnType<typeof vi.fn>; typeof vi.fn<(productId: string, updates: { name: string; category: string; barcode?: string }) => void>
>;
let onDelete: ReturnType<typeof vi.fn<(productId: string) => void>>;
beforeEach(() => { beforeEach(() => {
onSave = vi.fn(); onSave = vi.fn();