import React from 'react';
import { faStar, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { render, fireEvent } from '@testing-library/react-native';
import { NavActions } from './NavActions';

const actions = [
   {
      id: 'star',
      item: <FontAwesomeIcon icon={faStar} color="white" />, // <i className="fas fa-star" />,
      onPress: () => {},
   },
   {
      id: 'unstar',
      item: <FontAwesomeIcon icon={faStar} color="white" />, // <i className="far fa-star" />,
      onPress: () => {},
   },
   {
      id: 'delete',
      item: <FontAwesomeIcon icon={faTrashAlt} color="white" />, // <i className="far fa-trash-alt" />,
      onPress: () => {},
   },
];

it('renderizar NavActions padrão', () => {
   const { toJSON } = render(<NavActions actions={actions} onUnselectAll={() => {}} selected={0} />);
   expect(toJSON).toMatchSnapshot();
});

it('renderizar NavActions com número no select', () => {
   const { toJSON } = render(<NavActions actions={actions} onUnselectAll={() => {}} selected={10} />);
   expect(toJSON).toMatchSnapshot();
});

it('testar onUnselectAll', (done) => {
   function onUnselectAll(): void {
      done();
   }
   
   const { getByTestId } = render(<NavActions actions={actions} onUnselectAll={onUnselectAll} selected={10} />);

   fireEvent.press(getByTestId('deselect'));
});
