diff --git a/test/lazy-define.ts b/test/lazy-define.ts index b2a040f..bfa9f91 100644 --- a/test/lazy-define.ts +++ b/test/lazy-define.ts @@ -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``) + + await new Promise(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``) + lazyDefine('later-defined-element-test', onDefine) + + await new Promise(resolve => requestAnimationFrame(resolve)) + + expect(onDefine).to.be.callCount(1) + }) + it("doesn't call the same callback twice", () => {}) })