mithril-vndb/render/tests/test-createFragment.js
Isiah Meadows 1f4b2cf49a
Deservicify core (#2458)
* De-servicify router (mostly)

Still uses the redraw service, but it no longer has an intermediate
service of its own.

Also, did a *lot* of test deduplication in this. About 30-40% of the
router service tests were already tested on the main router API instance
itself.

Bundle size decreased from 9560 to 9548 bytes min+gzip.

* Merge `m.mount` + `m.redraw`, update router

Simplifies the router and redraw mechanism, and makes it much easier to
keep predictable.

Bundle size down to 9433 bytes min+gzip, docs updated accordingly.

* Make `mithril/render` just return the `m.render` function directly.

* Deservicify `m.render`, revise `m.route`

- You now have to use `mithril/render/render` directly if you want an
  implicit redraw function. (This will likely be going away in v3.)
- Revise `m.route` to only `key` components

* Add `redraw` to `m.render`, deservicify requests

* Test error logging

* Update docs + changelog [skip ci]
2019-07-07 18:28:43 -04:00

50 lines
1.2 KiB
JavaScript

"use strict"
var o = require("../../ospec/ospec")
var domMock = require("../../test-utils/domMock")
var vdom = require("../../render/render")
o.spec("createFragment", function() {
var $window, root, render
o.beforeEach(function() {
$window = domMock()
root = $window.document.createElement("div")
render = vdom($window)
})
o("creates fragment", function() {
var vnode = {tag: "[", children: [{tag: "a"}]}
render(root, [vnode])
o(vnode.dom.nodeName).equals("A")
})
o("handles empty fragment", function() {
var vnode = {tag: "[", children: []}
render(root, [vnode])
o(vnode.dom).equals(null)
o(vnode.domSize).equals(0)
})
o("handles childless fragment", function() {
var vnode = {tag: "["}
render(root, [vnode])
o(vnode.dom).equals(null)
o(vnode.domSize).equals(0)
})
o("handles multiple children", function() {
var vnode = {tag: "[", children: [{tag: "a"}, {tag: "b"}]}
render(root, [vnode])
o(vnode.domSize).equals(2)
o(vnode.dom.nodeName).equals("A")
o(vnode.dom.nextSibling.nodeName).equals("B")
})
o("handles td", function() {
var vnode = {tag: "[", children: [{tag: "td"}]}
render(root, [vnode])
o(vnode.dom).notEquals(null)
o(vnode.dom.nodeName).equals("TD")
})
})