Fix type issues in tests

This commit is contained in:
beatz174-bit
2025-12-01 22:00:27 +10:00
parent 5edc2057be
commit 6917d944fe
2 changed files with 8 additions and 4 deletions
@@ -57,7 +57,7 @@ describe('AddProductDialog', () => {
});
it('applies initialBarcode and triggers lookup', async () => {
fetchProductSpy.mockResolvedValue({ name: 'From OFF' });
fetchProductSpy.mockResolvedValue({ name: 'From OFF', source: 'openfoodfacts' });
render(
<AddProductDialog
@@ -2,6 +2,7 @@ import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi, beforeEach } from 'vitest';
import { ProductRow } from '../ProductRow';
import type { Product } from '../../models/Product';
import { makeNamedError } from '../../test/makeNamedError';
vi.mock('../BarcodeScannerView', () => ({
@@ -18,20 +19,23 @@ const categoriesById = new Map([
['cat-2', 'Drinks'],
]);
const baseProduct = {
const baseProduct: Product = {
id: 'p1',
name: 'Product One',
category: 'cat-1',
unit_type: 'unit',
bulk_name: 'carton',
barcode: undefined,
archived: false,
created_at: 0,
updated_at: 0,
};
describe('ProductRow error handling', () => {
let onSave: ReturnType<typeof vi.fn>;
let onDelete: ReturnType<typeof vi.fn>;
let onSave: ReturnType<
typeof vi.fn<(productId: string, updates: { name: string; category: string; barcode?: string }) => void>
>;
let onDelete: ReturnType<typeof vi.fn<(productId: string) => void>>;
beforeEach(() => {
onSave = vi.fn();