import { Injector, runInInjectionContext } from '@angular/core';
import { CustomEmojiService } from '../../../../../../custom-emoji';
import { ChatMessageMarkdownComponent } from './chat-message-markdown.component';

describe('ChatMessageMarkdownComponent', () => {
  function createComponent(): ChatMessageMarkdownComponent {
    const injector = Injector.create({
      providers: [
        ChatMessageMarkdownComponent,
        {
          provide: CustomEmojiService,
          useValue: {
            findEmoji: vi.fn(),
            emojis: vi.fn(() => [])
          }
        }
      ]
    });

    return runInInjectionContext(injector, () => injector.get(ChatMessageMarkdownComponent));
  }

  it('marks custom emoji hosts with ids for the global context menu', () => {
    const component = createComponent();

    expect(component.isCustomEmojiMarkdownImage('custom-emoji:party-id:party')).toBe(true);
    expect(component.getCustomEmojiId('custom-emoji:party-id:party')).toBe('party-id');
    expect(component.isCustomEmojiMarkdownImage('Shared image')).toBe(false);
    expect(component.getCustomEmojiId('Shared image')).toBeNull();
  });
});
