wcb/test/e2e/templating.test.mjs
Ayo ce30b114a2 chore: new demo workspace & e2e tests
- this adds a new demo web app with vite HMR for development
- all examples are covered with e2e tests
2026-07-05 15:40:53 +02:00

25 lines
786 B
JavaScript

import { beforeEach, expect, test } from 'vitest'
import '../../demo/examples/templating/index.js'
beforeEach(() => {
document.body.innerHTML = ''
})
test('renders interpolated lists and links and counts on click', () => {
document.body.innerHTML = '<my-counter></my-counter>'
const el = document.querySelector('my-counter')
expect(el.querySelector('#btn span').textContent.trim()).toBe('123')
const paragraphs = [...el.querySelectorAll('p')].map((p) =>
p.textContent.trim()
)
expect(paragraphs).toContain('what')
const links = el.querySelectorAll('li a')
expect(links.length).toBe(2)
expect(links[0].getAttribute('href')).toBe('https://ayco.io')
el.querySelector('#btn').click()
expect(el.querySelector('#btn span').textContent.trim()).toBe('124')
})