/** @jest-environment jsdom */ import { parseDocumentFromString, serializeDocumentIntoString } from 'botframework-webchat-component/internal'; import MarkdownIt from 'markdown-it'; import betterLink from '../markdownItPlugins/betterLink'; import betterLinkDocumentMod, { type BetterLinkDocumentModDecoration } from './betterLinkDocumentMod'; const BASE_MARKDOWN = '[Example](https://example.com)'; const BASE_HTML = new MarkdownIt().render(BASE_MARKDOWN); describe('When passing "asButton" option with true', () => { let actual: Document; const decoration: BetterLinkDocumentModDecoration = { asButton: true }; beforeEach(() => { actual = betterLinkDocumentMod(parseDocumentFromString(BASE_HTML), () => decoration); }); test('should replace with

\n' )); test('should match baseline', () => expect(serializeDocumentIntoString(actual)).toBe( serializeDocumentIntoString( parseDocumentFromString(new MarkdownIt().use(betterLink, () => decoration).render(BASE_MARKDOWN)) ) )); }); describe('When passing "asButton" option with true and "iconClassName" with "my-icon"', () => { let actual: Document; const decoration: BetterLinkDocumentModDecoration = { asButton: true, iconClassName: 'my-icon' }; beforeEach(() => { actual = betterLinkDocumentMod(parseDocumentFromString(BASE_HTML), () => decoration); }); test('should replace with

\n' )); test('should match baseline', () => expect(serializeDocumentIntoString(actual)).toBe( serializeDocumentIntoString( parseDocumentFromString(new MarkdownIt().use(betterLink, () => decoration).render(BASE_MARKDOWN)) ) )); }); describe('When passing "asButton" option with true and "title" with "Hello, World!"', () => { let actual: Document; const decoration: BetterLinkDocumentModDecoration = { asButton: true, title: 'Hello, World!' }; beforeEach(() => { actual = betterLinkDocumentMod(parseDocumentFromString(BASE_HTML), () => decoration); }); test('should replace with

\n' )); test('should match baseline', () => expect(serializeDocumentIntoString(actual)).toBe( serializeDocumentIntoString( parseDocumentFromString(new MarkdownIt().use(betterLink, () => decoration).render(BASE_MARKDOWN)) ) )); }); describe('When passing "asButton" option with true and "className" with "my-link"', () => { let actual: Document; const decoration: BetterLinkDocumentModDecoration = { asButton: true, className: 'my-link' }; beforeEach(() => { actual = betterLinkDocumentMod(parseDocumentFromString(BASE_HTML), () => decoration); }); test('should replace with

\n' )); test('should match baseline', () => expect(serializeDocumentIntoString(actual)).toBe( serializeDocumentIntoString( parseDocumentFromString(new MarkdownIt().use(betterLink, () => decoration).render(BASE_MARKDOWN)) ) )); }); describe('When passing "asButton" option with true and "aria-label" with "Hello, World!"', () => { let actual: Document; const decoration: BetterLinkDocumentModDecoration = { asButton: true, ariaLabel: 'Hello, World!' }; beforeEach(() => { actual = betterLinkDocumentMod(parseDocumentFromString(BASE_HTML), () => decoration); }); test('should replace with

\n' )); test('should match baseline', () => expect(serializeDocumentIntoString(actual)).toBe( serializeDocumentIntoString( parseDocumentFromString(new MarkdownIt().use(betterLink, () => decoration).render(BASE_MARKDOWN)) ) )); });