import type { Attachment } from 'stream-chat' import { describe, expect, it } from 'vitest' import { isLinkAttachment } from '.' describe('isLinkAttachment', () => { it('is true for a Stream link-type attachment', () => { expect(isLinkAttachment({ type: 'link' } as Attachment)).toBe(true) }) it('is true for an og_scrape_url with no asset_url', () => { expect( isLinkAttachment({ og_scrape_url: 'https://example.com' } as Attachment) ).toBe(true) }) it('ignores a whitespace-only og_scrape_url', () => { expect(isLinkAttachment({ og_scrape_url: ' ' } as Attachment)).toBe(false) }) it('is false when og_scrape_url accompanies an asset_url (media, not a link)', () => { expect( isLinkAttachment({ og_scrape_url: 'https://example.com', asset_url: 'https://cdn.example.com/file.mp4', } as Attachment) ).toBe(false) }) it('is false for a plain attachment with neither', () => { expect(isLinkAttachment({ type: 'image' } as Attachment)).toBe(false) }) })