import { expect, fixture, html, elementUpdated } from '@open-wc/testing'; import './nile-rte-link'; import type { NileRteLink } from './nile-rte-link'; function createEditor(content = '
hello world
'): HTMLElement { const el = document.createElement('article'); el.setAttribute('contenteditable', 'true'); el.innerHTML = content; document.body.appendChild(el); return el; } function selectText(node: Node, start: number, end: number) { const sel = document.getSelection()!; sel.removeAllRanges(); const range = document.createRange(); const textNode = node.firstChild!; range.setStart(textNode, start); range.setEnd(textNode, end); sel.addRange(range); return range; } function collapseAt(node: Node, offset: number) { const sel = document.getSelection()!; sel.removeAllRanges(); const range = document.createRange(); const textNode = node.firstChild!; range.setStart(textNode, offset); range.collapse(true); sel.addRange(range); return range; } function sleep(ms: number) { return new Promise(r => setTimeout(r, ms)); } describe('NileRteLink', () => { let editor: HTMLElement; afterEach(() => { editor?.remove(); }); // ── Rendering and Defaults ── it('1. renders the component', async () => { editor = createEditor(); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturehello world
'); const el = await fixturehello world
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const el = await fixturetext
'); const container = await fixture(html`normal link text
'); const el = await fixture