import React from 'react';
import renderer from 'react-test-renderer';
import { render, fireEvent, screen } from '@testing-library/react';
import { NavActions } from './NavActions';
import 'jest-styled-components';

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

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

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

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

   fireEvent.click(screen.getByTestId('deselect'));
});
