Add some basic tests for `lazyDefine`

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
This commit is contained in:
Kristján Oddsson 2022-08-01 17:06:44 +02:00
Родитель ec912f202d
Коммит a0c45c462e
1 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -30,5 +30,23 @@ describe('addStrategy', () => {
})
describe('lazyDefine', () => {
it('', () => {})
it('scans the whole document on first call', async () => {
const onDefine = spy()
lazyDefine('scan-document-test', onDefine)
await fixture(html`<scan-document-test></scan-document-test>`)
await new Promise<unknown>(resolve => requestAnimationFrame(resolve))
expect(onDefine).to.be.callCount(1)
})
it('initializes dynamic elements that are defined after the document is ready', async () => {
const onDefine = spy()
await fixture(html`<later-defined-element-test></later-defined-element-test>`)
lazyDefine('later-defined-element-test', onDefine)
await new Promise<unknown>(resolve => requestAnimationFrame(resolve))
expect(onDefine).to.be.callCount(1)
})
it("doesn't call the same callback twice", () => {})
})