Skip to content

Commit

Permalink
Improve link test
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Jul 21, 2023
1 parent b0726cf commit 4635577
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions test/browser/link.test.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4635577

Please sign in to comment.