Skip to content

Commit a20cf7e

Browse files
committed
fix: resolve TypeScript errors in tests and qr utility
1 parent ead97a8 commit a20cf7e

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/features/bins/__tests__/useBulkActions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const t: Terminology = {
6868
};
6969

7070
describe('useBulkActions', () => {
71-
let clearSelection: ReturnType<typeof vi.fn>;
72-
let showToast: ReturnType<typeof vi.fn>;
71+
let clearSelection: () => void;
72+
let showToast: (toast: { message: string; action?: { label: string; onClick: () => void } }) => void;
7373

7474
beforeEach(() => {
7575
vi.clearAllMocks();

src/features/bins/__tests__/useEditBinForm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('useEditBinForm', () => {
103103
});
104104

105105
it('saveEdit calls updateBin with correct payload', async () => {
106-
vi.mocked(updateBin).mockResolvedValue({} as Bin);
106+
vi.mocked(updateBin).mockResolvedValue(undefined);
107107
const { result } = renderHook(() => useEditBinForm('abc123'));
108108
act(() => result.current.startEdit(mockBin));
109109
await act(() => result.current.saveEdit());

src/lib/__tests__/usePermissions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('usePermissions', () => {
113113

114114
it('isLoading passes through from useLocationList', () => {
115115
setup('admin');
116-
mockUseLocationList.mockReturnValue({ locations: [], isLoading: true } as ReturnType<typeof useLocationList>);
116+
mockUseLocationList.mockReturnValue({ locations: [], isLoading: true, refresh: vi.fn() } as ReturnType<typeof useLocationList>);
117117
const { result } = renderHook(() => usePermissions());
118118
expect(result.current.isLoading).toBe(true);
119119
});

src/lib/qr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function makeLruCache(maxSize: number = 200) {
4343
}
4444

4545
/** Convert raw QR output (Blob or ArrayBuffer) to a data URL string. */
46-
export async function rawQrToDataURL(raw: Blob | ArrayBuffer): Promise<string> {
47-
const blob = raw instanceof Blob ? raw : new Blob([raw], { type: 'image/png' });
46+
export async function rawQrToDataURL(raw: Blob | ArrayBuffer | Buffer): Promise<string> {
47+
const blob = raw instanceof Blob ? raw : new Blob([raw instanceof ArrayBuffer ? raw : new Uint8Array(raw)], { type: 'image/png' });
4848
return new Promise<string>((resolve, reject) => {
4949
const reader = new FileReader();
5050
reader.onloadend = () => resolve(reader.result as string);

0 commit comments

Comments
 (0)