import {mount} from '@vue/test-utils';
import {nextTick} from 'vue';

import {describe, expect, it, vi} from 'vitest';

import ChatTimeMarkdown from '../ChatTimeMarkdown.vue';

vi.mock('@easyflow-core/preferences', () => ({
  usePreferences: () => ({
    isDark: false,
  }),
}));

describe('ChatTimeMarkdown', () => {
  it('renders mermaid code fences with the shared mermaid block', async () => {
    const wrapper = mount(ChatTimeMarkdown, {
      props: {
        content: [
          '```mermaid',
          'flowchart TD',
          'A[开始] --> B[结束]',
          '```',
        ].join('\n'),
      },
    });

    await nextTick();

    expect(wrapper.find('.incremark-mermaid').exists()).toBe(true);
    expect(wrapper.find('.mermaid-header').text().toLowerCase()).toContain(
      'mermaid',
    );
    expect(wrapper.find('.mermaid-source-code').text()).toContain(
      'flowchart TD',
    );
  });
});
