-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove root property in favor of container as 2nd argument. Close #410.
- Loading branch information
1 parent
54de0fd
commit 87efaf8
Showing
6 changed files
with
124 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { h, app } from "../src" | ||
|
||
window.requestAnimationFrame = setTimeout | ||
|
||
beforeEach(() => { | ||
document.body.innerHTML = "" | ||
}) | ||
|
||
test("container", done => { | ||
document.body.innerHTML = "<main></main>" | ||
app( | ||
{ | ||
view: state => | ||
h( | ||
"div", | ||
{ | ||
oncreate() { | ||
expect(document.body.innerHTML).toBe("<main><div>foo</div></main>") | ||
done() | ||
} | ||
}, | ||
"foo" | ||
) | ||
}, | ||
document.body.firstChild | ||
) | ||
}) | ||
|
||
test("nested container", done => { | ||
document.body.innerHTML = "<main><section></section><div></div></main>" | ||
|
||
app( | ||
{ | ||
view: state => | ||
h( | ||
"p", | ||
{ | ||
oncreate() { | ||
expect(document.body.innerHTML).toBe( | ||
`<main><section></section><div><p>foo</p></div></main>` | ||
) | ||
done() | ||
} | ||
}, | ||
"foo" | ||
) | ||
}, | ||
document.body.firstChild.lastChild | ||
) | ||
}) | ||
|
||
test("container with mutated host", done => { | ||
document.body.innerHTML = "<main><div></div></main>" | ||
|
||
const host = document.body.firstChild | ||
const container = host.firstChild | ||
|
||
app( | ||
{ | ||
view: (state, actions) => | ||
h( | ||
"p", | ||
{ | ||
oncreate() { | ||
expect(document.body.innerHTML).toBe( | ||
`<main><div><p>foo</p></div></main>` | ||
) | ||
|
||
host.insertBefore( | ||
document.createElement("header"), | ||
host.firstChild | ||
) | ||
host.appendChild(document.createElement("footer")) | ||
|
||
actions.bar() | ||
}, | ||
onupdate() { | ||
expect(document.body.innerHTML).toBe( | ||
`<main><header></header><div><p>bar</p></div><footer></footer></main>` | ||
) | ||
done() | ||
} | ||
}, | ||
state.value | ||
), | ||
state: { | ||
value: "foo" | ||
}, | ||
actions: { | ||
bar(state) { | ||
return { | ||
value: "bar" | ||
} | ||
} | ||
} | ||
}, | ||
container | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.