// import { expect, test } from '@jest/globals';
import { fireEvent, render, screen } from '@testing-library/react';
import { composeStories } from '@storybook/react';
import '@testing-library/jest-dom';

import * as DemoStories from './demo.stories';

const { BasePegaDxilMyIconButtonUrl } = composeStories(DemoStories);

test('renders PegaDxilMyIconButtonUrl', async () => {
  render(<BasePegaDxilMyIconButtonUrl />);
  expect(await screen.findByText('State list for USA')).toBeVisible();

  expect(screen.queryByText('Massachusetts')).not.toBeInTheDocument();
  expect(screen.queryByText('Rhode Island')).not.toBeInTheDocument();
  expect(screen.queryByText('Connecticut')).not.toBeInTheDocument();

  const iconButton = screen.getByRole('button');
  fireEvent.click(iconButton);

  expect(await screen.findByText('Massachusetts')).toBeVisible();
  expect(await screen.findByText('Rhode Island')).toBeVisible();
  expect(await screen.findByText('Connecticut')).toBeVisible();

  const iconLink = screen.getByRole('link');
  expect(iconLink).toHaveAttribute('href', 'about:blank');
});
