import React from 'react';
import { MinimizedView } from './minimizedview';
import { fireEvent, render } from '@testing-library/react-native';
import { MinimizedViewProps } from './type';

describe('MinimizedView', () => {
  const onPressMock = jest.fn();
  const props: MinimizedViewProps = {
    title: 'Anchored in Peace',
    description: 'Andy Wood',
    testID: 'MZV-1',
    onPress: onPressMock,
    buttonText: 'MV Button',
  };

  it('should render', () => {
    const { getByText } = render(<MinimizedView {...props} />);
    expect(getByText('Anchored in Peace')).toBeDefined();
  });

  it('should render button', () => {
    const { getByText } = render(<MinimizedView {...props} />);
    expect(getByText('MV Button')).toBeDefined();
  });

  it('should render desc', () => {
    const { getByTestId } = render(<MinimizedView {...props} />);
    const desc = getByTestId('hcds-mobile-text-minimized-view-desc-MZV-1');
    expect(desc).toBeTruthy();
  });

  it('should call onPress', () => {
    const { getByTestId } = render(<MinimizedView {...props} />);
    const mvBtn = getByTestId('hcds-mobile-btn-minimized-view-MZV-1');
    fireEvent.press(mvBtn);
    expect(onPressMock).toHaveBeenCalled();
  });
});
