/* @vitest-environment jsdom */

import { render, screen } from '@testing-library/react';
import { expect, test } from 'vitest';

import { CopyFeedbackMessage } from './CopyFeedbackMessage';

test('renders nothing while copy feedback is idle', () => {
  const { container } = render(
    <CopyFeedbackMessage state="idle" className="copy-toast" />,
  );

  expect(container.textContent).toBe('');
});

test('renders copied and failed feedback labels', () => {
  const { rerender } = render(
    <CopyFeedbackMessage
      state="copied"
      copiedLabel="分享内容已复制"
      failedLabel="分享失败"
      className="copy-toast"
    />,
  );

  const copied = screen.getByText('分享内容已复制');
  expect(copied.className).toContain('copy-toast');

  rerender(
    <CopyFeedbackMessage
      state="failed"
      copiedLabel="分享内容已复制"
      failedLabel="分享失败"
      className="copy-toast"
    />,
  );

  expect(screen.getByText('分享失败')).toBeTruthy();
});
