import { fireEvent } from '@testing-library/dom' import { expect, test } from 'vitest' import littlefoot from '../../src/littlefoot' import { getButton, setDocumentBody, waitToStopChanging } from '../helper' test('setup with default contentTemplate', async () => { setDocumentBody('single.html') littlefoot({ activateDelay: 1 }) const button = getButton('1') fireEvent.click(button) await waitToStopChanging(button) const footnote = document.querySelector('aside') expect(footnote?.dataset).toMatchObject({ footnoteId: '1', footnotePopover: '', }) const content = footnote?.querySelector('.littlefoot__content') expect(content).toContainHTML(`This is the document's only footnote.`) }) test('setup with custom contentTemplate using <%= %> delimiters', async () => { setDocumentBody('single.html') littlefoot({ activateDelay: 1, contentTemplate: ``, }) const button = getButton('1') fireEvent.click(button) await waitToStopChanging(button) const footnote = document.querySelector('aside.custom') expect(footnote?.dataset).toMatchObject({ footnoteId: '1', footnotePopover: '', testId: '1', testNumber: '1', }) const content = footnote?.querySelector('.littlefoot__content') expect(content).toContainHTML(`This is the document's only footnote.`) }) test('setup with custom contentTemplate using <% %> delimiters', async () => { setDocumentBody('single.html') littlefoot({ activateDelay: 1, contentTemplate: ``, }) const button = getButton('1') fireEvent.click(button) await waitToStopChanging(button) const footnote = document.querySelector('aside.custom') expect(footnote?.dataset).toMatchObject({ footnoteId: '1', footnotePopover: '', testId: '1', testNumber: '1', }) const content = footnote?.querySelector('.littlefoot__content') expect(content).toContainHTML(`This is the document's only footnote.`) })