import React from 'react'; import { render } from '@testing-library/react'; import { memori, tenant, integration } from './mocks/data'; import Memori from './index'; // Mock fetch for API calls globalThis.fetch = jest.fn(() => Promise.resolve({ ok: true, json: () => Promise.resolve({}), }) ) as jest.Mock; // Mock matchMedia for tests Object.defineProperty(window, 'matchMedia', { writable: true, value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, addListener: jest.fn(), // deprecated removeListener: jest.fn(), // deprecated addEventListener: jest.fn(), removeEventListener: jest.fn(), dispatchEvent: jest.fn(), })), }); // Mock window.location const mockLocation = { hostname: 'localhost', href: 'http://localhost:3000', }; Object.defineProperty(window, 'location', { value: mockLocation, writable: true, }); it('renders client', () => { const { container } = render( ); expect(container).toMatchSnapshot(); }); it('renders client with all the props', () => { const { container } = render( {}} additionalInfo={{}} customMediaRenderer={() =>
Custom Media Renderer
} additionalSettings={
Additional Settings
} userAvatar="https://memori.ai/avatar.png" applyVarsToRoot={true} disableTextEnteredEvents={true} /> ); expect(container).toMatchSnapshot(); }); it('renders client with whiteListedDomains on allowed domains', () => { mockLocation.hostname = 'memori.ai'; const { container } = render( ); expect(container).toMatchSnapshot(); }); it('renders client with whiteListedDomains on not allowed domains', () => { mockLocation.hostname = 'aisuru.com'; const { container } = render( ); expect(container).toMatchSnapshot(); }); it('renders client with audio disabled', () => { const { container } = render( ); expect(container).toMatchSnapshot(); });