Created
December 13, 2016 17:31
-
-
Save bdchauvette/bc9205a33538e025f1e503dc0211b171 to your computer and use it in GitHub Desktop.
mithril-node-render: components with children
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
global.window = require('mithril/test-utils/browserMock')() | |
global.document = window.document | |
const m = require('mithril') | |
const o = require('mithril/ospec/ospec') | |
const renderToString = require('mithril-node-render') | |
const ParentComponent = { | |
view(node) { | |
return m('div', node.children) | |
} | |
} | |
// ============================================================================= | |
o('html tag', () => { | |
// Normal divs works fine | |
o(renderToString(m('div', 'howdy'))).equals('<div>howdy</div>') | |
o(renderToString(m('div', m('span', 'howdy')))).equals('<div><span>howdy</span></div>') | |
}) | |
o('parent component', () => { | |
// But components don't | |
o(renderToString(m(ParentComponent, 'howdy'))).equals('<div>howdy</div>') | |
o(renderToString(m(ParentComponent, m('span', 'howdy')))).equals('<div><span>howdy</span></div>') | |
}) | |
o.run() |
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
{ | |
"dependencies": { | |
"mithril": "https://github.com/lhorie/mithril.js/tarball/rewrite", | |
"mithril-node-render": "^1.0.1-3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment