import '@testing-library/jest-dom';
import React from 'react';
import { describe, expect, it } from 'vitest';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import { renderWithProviders } from '../renderWithProviders';
import routes from '../routes';
import { showSnackbar } from '../slices/snackbarSlice';
import setupStore from '../store';

describe('Global Snackbar', async () => {
  const memoryRouter = createMemoryRouter(routes, {
    initialEntries: ['/'],
  });
  it('displays message', async () => {
    const store = setupStore();
    store.dispatch(
      showSnackbar({
        message: 'message',
        severity: 'success',
      })
    );
    const { findByText } = renderWithProviders(
      <RouterProvider router={memoryRouter} />,
      { store }
    );
    expect(await findByText(/message/i)).toBeInTheDocument();
  });
});
