Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

3.0 KB
Raw Blame
import EnvelopeIcon from '@icon/system/regular/envelope.svg';
import FileIcon from '@icon/system/regular/file.svg';
import FilePdfIcon from '@icon/system/regular/file-pdf.svg';
import HashIcon from '@icon/system/regular/hash-straight.svg';
import { describe, expect, it } from 'vitest';
import {
  getSearchIcon,
  getSenderId,
} from '../extractors-search/search-helpers';
import type { ContentHitData } from '../types/search';

describe('search-helpers', () => {
  describe('getSenderId', () => {
    it('returns senderId for channel type hits', () => {
      const hit: ContentHitData = {
        type: 'channel',
        senderId: 'user123',
      } as ContentHitData;

      expect(getSenderId(hit)).toBe('user123');
    });

    it('returns senderId for email type hits', () => {
      const hit: ContentHitData = {
        type: 'email',
        senderId: 'user456',
      } as ContentHitData;

      expect(getSenderId(hit)).toBe('user456');
    });

    it('returns undefined for md type hits', () => {
      const hit: ContentHitData = {
        type: 'md',
      } as ContentHitData;

      expect(getSenderId(hit)).toBeUndefined();
    });

    it('returns undefined for pdf type hits', () => {
      const hit: ContentHitData = {
        type: 'pdf',
      } as ContentHitData;

      expect(getSenderId(hit)).toBeUndefined();
    });

    it('handles channel hits without senderId', () => {
      const hit: ContentHitData = {
        type: 'channel',
      } as ContentHitData;

      expect(getSenderId(hit)).toBeUndefined();
    });

    it('handles email hits without senderId', () => {
      const hit: ContentHitData = {
        type: 'email',
      } as ContentHitData;

      expect(getSenderId(hit)).toBeUndefined();
    });
  });

  describe('getSearchIcon', () => {
    it('returns FileIcon for md type', () => {
      const hit: ContentHitData = {
        type: 'md',
      } as ContentHitData;

      expect(getSearchIcon(hit)).toBe(FileIcon);
    });

    it('returns FilePdfIcon for pdf type', () => {
      const hit: ContentHitData = {
        type: 'pdf',
      } as ContentHitData;

      expect(getSearchIcon(hit)).toBe(FilePdfIcon);
    });

    it('returns HashIcon for channel type', () => {
      const hit: ContentHitData = {
        type: 'channel',
      } as ContentHitData;

      expect(getSearchIcon(hit)).toBe(HashIcon);
    });

    it('returns EnvelopeIcon for email type', () => {
      const hit: ContentHitData = {
        type: 'email',
      } as ContentHitData;

      expect(getSearchIcon(hit)).toBe(EnvelopeIcon);
    });

    it('returns FileIcon for unknown types', () => {
      const hit: ContentHitData = {
        type: 'unknown' as any,
      } as ContentHitData;

      expect(getSearchIcon(hit)).toBe(FileIcon);
    });

    it('handles hits with additional properties', () => {
      const hit: ContentHitData = {
        type: 'channel',
        senderId: 'user123',
        content: 'some content',
      } as ContentHitData;

      expect(getSearchIcon(hit)).toBe(HashIcon);
    });
  });
});