UNPKG

pinata-expo-hooks

Version:

React Native/Expo hooks for Pinata TUS uploads

32 lines (31 loc) 852 B
import '@testing-library/jest-dom'; import 'whatwg-fetch'; // Polyfill for fetch // Mock global fetch global.fetch = jest.fn(); // Mock Response constructor global.Response = Response; global.Headers = Headers; // Mock setTimeout for controlling timing in tests jest.useFakeTimers(); // Mock expo-file-system globally jest.mock('expo-file-system', () => ({ getInfoAsync: jest.fn(), readAsStringAsync: jest.fn(), EncodingType: { Base64: 'base64', UTF8: 'utf8', }, })); // Mock Base64 globally jest.mock('Base64', () => ({ __esModule: true, default: { btoa: (str) => Buffer.from(str, 'binary').toString('base64'), atob: (str) => Buffer.from(str, 'base64').toString('binary'), }, })); // Reset all mocks after each test afterEach(() => { jest.clearAllMocks(); jest.clearAllTimers(); });