import { render, screen, fireEvent } from '@testing-library/react';

import { Dialog } from '.';
import { Button } from '../button';

describe('testing the dialog', () => {
  it('should open', () => {
    render(
      <Dialog>
        <Dialog.Trigger asChild>
          <Button>Open dialog</Button>
        </Dialog.Trigger>
        <Dialog.Content>
          <Dialog.Title>This is a normal dialog</Dialog.Title>
          <Dialog.Description>That is described in a declarative way</Dialog.Description>
          <div className="flex items-center justify-between">Hello world!</div>
        </Dialog.Content>
      </Dialog>,
    );

    fireEvent.click(screen.getByText('Open dialog'));

    expect(screen.getByText('This is a normal dialog')).toBeVisible();
  });
});
