mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
var expect = require("chai").expect;
|
|
|
|
module.exports = function (helpers) {
|
|
var component = helpers.mount(require.resolve("./index"), {});
|
|
|
|
expect(component.el.childNodes.length).to.equal(1);
|
|
expect(component.el.firstChild.nodeName).to.equal("INPUT");
|
|
expect(component.el.firstChild.value).to.equal("x");
|
|
|
|
component.state.html = "<textarea>HELLO WORLD!</textarea>";
|
|
component.update();
|
|
|
|
expect(component.el.childNodes.length).to.equal(1);
|
|
expect(component.el.firstChild.nodeName).to.equal("TEXTAREA");
|
|
expect(component.el.firstChild.value).to.equal("HELLO WORLD!");
|
|
|
|
component.state.html =
|
|
'<select><option value="1">One</option><option value="2" selected>Two</option></select>';
|
|
component.update();
|
|
|
|
expect(component.el.childNodes.length).to.equal(1);
|
|
expect(component.el.firstChild.nodeName).to.equal("SELECT");
|
|
expect(component.el.firstChild.selectedIndex).to.equal(1);
|
|
|
|
component.state.html =
|
|
'<!-- A comment -->';
|
|
component.update();
|
|
|
|
expect(component.el.childNodes.length).to.equal(1);
|
|
expect(component.el.firstChild.nodeType).to.equal(Node.COMMENT_NODE);
|
|
expect(component.el.firstChild.data).to.equal(" A comment ");
|
|
};
|