From 46355775c318ac1d6f027321fa69961fbd46e724 Mon Sep 17 00:00:00 2001 From: yandeu <20306025+yandeu@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:20:19 +0200 Subject: [PATCH] Improve link test --- test/browser/link.test.html | 38 +++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/test/browser/link.test.html b/test/browser/link.test.html index e4fe5e9..46fb0c6 100644 --- a/test/browser/link.test.html +++ b/test/browser/link.test.html @@ -1,4 +1,4 @@ - + @@ -70,12 +70,38 @@ headLastChild().remove() }) - describe('Back/Delay (TODO)', async () => { - const back = (Link, { back: true, href: 'https://nanojsx.github.io/' }, 'nanojsx.github.io') - const delay = (Link, { delay: 150, href: 'https://nanojsx.github.io/' }, 'nanojsx.github.io') + describe('Delay', async () => { + const App = () => h(Link, { delay: 1000, href: 'https://nanojsx.github.io/' }, 'nanojsx.github.io') - expect('skip', null).toBe(null, 'Should test "back"') - expect('skip', null).toBe(null, 'Should test "delay"') + render(App, root()) + + await Test.wait() + + /** @type {HTMLLinkElement} */ + const link = root()?.firstChild + link.click() + + await Test.wait(2000) + + expect(window.__gotohref__).toBe('https://nanojsx.github.io/') + }) + + describe('Back (target.href)', async () => { + const App = () => h(Link, { back: true, href: 'https://nanojsx.github.io/' }, 'nanojsx.github.io') + + render(App, root()) + + await Test.wait() + + /** @type {HTMLLinkElement} */ + const link = root()?.firstChild + link.click() + + expect(window.__gotohref__).toBe('https://nanojsx.github.io/') + }) + + describe('Back (window.history.back)', async () => { + expect('skip', null).toBe(null, 'Should test "window.history.back()"') }) Test.start()