import React from 'react';
import { SoluCXWidget, SoluCXWidgetView } from '../index';

jest.mock('react-native-webview', () => ({
    WebView: 'WebView',
}));

jest.mock('@react-native-async-storage/async-storage', () => ({
    __esModule: true,
    default: {
        setItem: jest.fn(() => Promise.resolve()),
        getItem: jest.fn(() => Promise.resolve(null)),
        removeItem: jest.fn(() => Promise.resolve()),
        clear: jest.fn(() => Promise.resolve()),
    },
}));

describe('package root exports', () => {
    it('exposes SoluCXWidget as the component API', () => {
        expect(SoluCXWidget).toBe(SoluCXWidgetView);
    });

    it('keeps the builder API on SoluCXWidget', () => {
        expect(typeof SoluCXWidget.create).toBe('function');
        expect(typeof SoluCXWidget.dismiss).toBe('function');
    });

    it('supports creating a JSX element with SoluCXWidget', () => {
        const element = (
            <SoluCXWidget
                soluCXKey="test-key"
                type="modal"
                data={{ journey: 'checkout', customer_id: 'user-1' }}
            />
        );

        expect(element.type).toBe(SoluCXWidgetView);
    });
});