import React from 'react';
import { injectIntl } from 'react-intl';
import '@testing-library/jest-dom';
import userEvent from '@testing-library/user-event';
import {
  render,
  screen,
} from '../../../utils/test-utils';
import CapDocumentUpload from '../index';
import { mockData } from './mockData';

const ComponentToRender = injectIntl(CapDocumentUpload);
const renderComponent = (props) => render(
  <ComponentToRender {...props} />
);

describe("test for document upload", () => {
  const props = {
    allowedExtensionsRegex: (/\.(pdf)$/i),
    documentSize: 16000000,
    uploadAsset: jest.fn(),
    documentSrc: '',
    updateDocumentSrc: jest.fn(),
    updateOnReUpload: jest.fn(),
    index: 0,
    className: 'cap-custom-document-upload',
    documentData: {},
    channel: 'WHATSAPP',
    channelSpecificStyle: null,
    whatsappDocParams: {},
    setWhatsappDocParams: jest.fn(),
    docPreview: <></>,
  };
  it("test for cap document upload", () => {
    renderComponent(props);
    expect(
      screen.getByText(/size upto:/i)
    ).toBeInTheDocument();
    expect(
      screen.getByText(/format:/i)
    ).toBeInTheDocument();
    expect(
      screen.getByText(/drag and drop document here/i)
    ).toBeInTheDocument();
    const button = screen.getByRole('button', {
      name: /drag and drop document here or select from computer/i,
    });
    userEvent.click(button);
  });
  it("test for cap document upload 1", () => {
    const props1 = {
      ...props,
      ...mockData,
    };
    renderComponent(props1);
  });
});
