is not interpreted as a tag, but as <b>
expect(n.node.childNodes.length).to.equal(1);
- expect(n.node.childNodes[0].nodeValue).to.equal("Omer: Simpson");
+ expect(n.node.childNodes[0].nodeValue.trim()).to.equal("Omer: Simpson");
n.$dispose();
});
@@ -180,12 +180,12 @@ describe("Sub-template insertion", function () {
};
var n = test3(dm, "answer is?");
- expect(n.node.childNodes[0].nodeValue).to.equal(" answer is? ");
+ expect(n.node.childNodes[0].nodeValue).to.equal(" answer is?\n ");
n.updateArgument(1, "answer is 42");
hsp.refresh();
- expect(n.node.childNodes[0].nodeValue).to.equal(" answer is 42 ");
+ expect(n.node.childNodes[0].nodeValue).to.equal(" answer is 42\n ");
n.$dispose();
});
@@ -196,7 +196,7 @@ describe("Sub-template insertion", function () {
};
var n = test5(dm);
- var input = n.node.childNodes[2];
+ var input = n.node.querySelector("input");
expect(input.value).to.equal("some text");
input.value = "foo";
@@ -219,7 +219,7 @@ describe("Sub-template insertion", function () {
};
var n = test6(dm);
- var input = n.node.childNodes[2];
+ var input = n.node.querySelector("input");
expect(input.value).to.equal("some text");
input.value = "bar";
@@ -239,7 +239,7 @@ describe("Sub-template insertion", function () {
};
var n = test6(dm);
- var input = n.node.childNodes[2];
+ var input = n.node.querySelector("input");
expect(input.value).to.equal("some text");
// change the whole attributes object, which is a root
@@ -259,7 +259,7 @@ describe("Sub-template insertion", function () {
};
var n = test7(dm);
- var input = n.node.childNodes[2];
+ var input = n.node.querySelector("input");
expect(input.value).to.equal("some text");
// change the whole attributes object, which is a root
diff --git a/test/rt/subtemplates2.spec.hsp b/test/rt/subtemplates2.spec.hsp
index ddaf60c..2458940 100644
--- a/test/rt/subtemplates2.spec.hsp
+++ b/test/rt/subtemplates2.spec.hsp
@@ -19,46 +19,40 @@ var ht=require("hsp/utils/hashtester"),
- Before -
- <#c.tpl/>
- - After
+ Before - <#c.tpl/> - After
- This is contentA
+This is contentA
- This is contentB
+This is contentB
- This is contentC
+This is contentC
- Before -
- <#c.a.b.tpl/>
- - After
+ Before - <#c.a.b.tpl/> - After
- Before -
- <#c.tpl msg="{c.txt}"/>
- - After
+ Before - <#c.tpl msg="{c.txt}"/> - After
- contentA2: {msg}
+contentA2: {msg}
- contentB2: {msg}
+contentB2: {msg}
var C2Controller=klass({
@@ -69,7 +63,7 @@ var C2Controller=klass({
});
- contentC2: {c.msg} {c.foo}
+contentC2: {c.msg} {c.foo}
var ctxt={
@@ -78,9 +72,7 @@ var ctxt={
}
- Before -
- <#ctxt.tpl msg="{ctxt.msg}"/>
- - After
+ Before - <#ctxt.tpl msg="{ctxt.msg}"/> - After
@@ -88,9 +80,7 @@ var ctxt={
{let x=c.a}
{let y=x.b}
- Before -
- <#y.tpl/>
- - After
+ Before - <#y.tpl/> - After
@@ -100,19 +90,19 @@ describe("Dynamic template insertion", function () {
test1(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentA - After");
+ expect(h(".content").text()).to.equal("Before - This is contentA \n - After");
// change template dynamically
h.$set(c,"tpl",contentB);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentB - After");
+ expect(h(".content").text()).to.equal("Before - This is contentB \n - After");
// change template dynamically, again
h.$set(c,"tpl",contentC);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentC - After");
+ expect(h(".content").text()).to.equal("Before - This is contentC \n - After");
h.$dispose();
});
@@ -122,25 +112,25 @@ describe("Dynamic template insertion", function () {
test2(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentA - After");
+ expect(h(".content").text()).to.equal("Before - This is contentA \n - After");
// change template dynamically
h.$set(c.a.b,"tpl",contentB);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentB - After");
+ expect(h(".content").text()).to.equal("Before - This is contentB \n - After");
// change path but not the template
h.$set(c.a,"b",{tpl:contentB,foo:"bar"});
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentB - After");
+ expect(h(".content").text()).to.equal("Before - This is contentB \n - After");
// change path and template
h.$set(c.a,"b",{tpl:contentC,foo:"bar"});
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentC - After");
+ expect(h(".content").text()).to.equal("Before - This is contentC \n - After");
h.$dispose();
});
@@ -150,25 +140,25 @@ describe("Dynamic template insertion", function () {
test3(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentA2: foo - After");
+ expect(h(".content").text()).to.equal("Before - contentA2: foo \n - After");
// change template dynamically
h.$set(c,"tpl",contentB2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentB2: foo - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: foo \n - After");
// change txt value
h.$set(c,"txt","bar");
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentB2: bar - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: bar \n - After");
// change template again dynamically
h.$set(c,"tpl",contentA2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentA2: bar - After");
+ expect(h(".content").text()).to.equal("Before - contentA2: bar \n - After");
h.$dispose();
});
@@ -178,13 +168,13 @@ describe("Dynamic template insertion", function () {
test4(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentA - After");
+ expect(h(".content").text()).to.equal("Before - This is contentA \n - After");
// change template dynamically
h.$set(c,"tpl",contentB2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentB2: hello - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: hello \n - After");
h.$dispose();
});
@@ -194,19 +184,19 @@ describe("Dynamic template insertion", function () {
test5(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentA - After");
+ expect(h(".content").text()).to.equal("Before - This is contentA \n - After");
// change intermediate object in the template path
h.$set(c,"a",{b:{tpl:contentB,foo:"bar"}});
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentB - After");
+ expect(h(".content").text()).to.equal("Before - This is contentB \n - After");
// change path and template
h.$set(c.a,"b",{tpl:contentC,foo:"bar"});
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentC - After");
+ expect(h(".content").text()).to.equal("Before - This is contentC \n - After");
h.$dispose();
});
@@ -216,27 +206,27 @@ describe("Dynamic template insertion", function () {
test4(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - This is contentA - After");
+ expect(h(".content").text()).to.equal("Before - This is contentA \n - After");
// change template to component
h.$set(c,"tpl",contentC2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentC2: hello foo - After");
+ expect(h(".content").text()).to.equal("Before - contentC2: hello foo \n - After");
h.$set(c,"msg","hello2");
- expect(h(".content").text()).to.equal("Before - contentC2: hello2 foo - After");
+ expect(h(".content").text()).to.equal("Before - contentC2: hello2 foo \n - After");
// change component to template
h.$set(c,"tpl",contentB2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentB2: hello2 - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: hello2 \n - After");
h.$set(c,"msg","hello");
- expect(h(".content").text()).to.equal("Before - contentB2: hello - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: hello \n - After");
// change again
h.$set(c,"tpl",contentC2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentC2: hello foo - After");
+ expect(h(".content").text()).to.equal("Before - contentC2: hello foo \n - After");
h.$dispose();
});
@@ -246,22 +236,22 @@ describe("Dynamic template insertion", function () {
test4(c).render(h.container);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentC2: hello foo - After");
+ expect(h(".content").text()).to.equal("Before - contentC2: hello foo \n - After");
h.$set(c,"msg","hello2");
- expect(h(".content").text()).to.equal("Before - contentC2: hello2 foo - After");
+ expect(h(".content").text()).to.equal("Before - contentC2: hello2 foo \n - After");
// change component to template
h.$set(c,"tpl",contentB2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentB2: hello2 - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: hello2 \n - After");
h.$set(c,"msg","hello3");
- expect(h(".content").text()).to.equal("Before - contentB2: hello3 - After");
+ expect(h(".content").text()).to.equal("Before - contentB2: hello3 \n - After");
// change template to component
h.$set(c,"tpl",contentC2);
expect(h.logs().length).to.equal(0);
- expect(h(".content").text()).to.equal("Before - contentC2: hello3 foo - After");
+ expect(h(".content").text()).to.equal("Before - contentC2: hello3 foo \n - After");
h.$dispose();
});
diff --git a/test/rt/text.spec.hsp b/test/rt/text.spec.hsp
index 86ff80e..2c7e27c 100644
--- a/test/rt/text.spec.hsp
+++ b/test/rt/text.spec.hsp
@@ -74,7 +74,7 @@ describe("Text Nodes", function () {
it("checks hello world text node - without any parameter", function () {
var n = hello1();
expect(n.node.firstChild.nodeType).to.equal(TEXT_NODE);
- expect(n.node.firstChild.nodeValue).to.equal("Hello World!");
+ expect(n.node.firstChild.nodeValue).to.equal(" Hello World!\n");
n.$dispose();
});
@@ -82,7 +82,7 @@ describe("Text Nodes", function () {
var n = hello2({
name : "Alexandre"
});
- expect(n.node.firstChild.nodeValue).to.equal("Hello Alexandre!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Alexandre!");
n.$dispose();
});
@@ -91,7 +91,7 @@ describe("Text Nodes", function () {
firstName : "Miles",
lastName : "Davis"
});
- expect(n.node.firstChild.nodeValue).to.equal("Hello Miles Davis!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Miles Davis!");
n.$dispose();
});
@@ -101,15 +101,15 @@ describe("Text Nodes", function () {
lastName : "Kahneman"
};
var n = hello3(dm);
- expect(n.node.firstChild.nodeValue).to.equal("Hello Daniel Kahneman!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Daniel Kahneman!");
json.set(dm, "lastName", "Craig");
- expect(n.node.firstChild.nodeValue).to.equal("Hello Daniel Kahneman!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Daniel Kahneman!");
n.refresh();
- expect(n.node.firstChild.nodeValue).to.equal("Hello Daniel Craig!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Daniel Craig!");
json.set(dm, "firstName", "Mickey");
json.set(dm, "lastName", "Mouse");
n.refresh();
- expect(n.node.firstChild.nodeValue).to.equal("Hello Mickey Mouse!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Mickey Mouse!");
n.$dispose();
});
@@ -125,14 +125,14 @@ describe("Text Nodes", function () {
};
var n2 = hello3(dm2);
- expect(n1.node.firstChild.nodeValue).to.equal("Hello Daniel Kahneman!");
- expect(n2.node.firstChild.nodeValue).to.equal("Hello Charles Darwin!");
+ expect(n1.node.firstChild.nodeValue.trim()).to.equal("Hello Daniel Kahneman!");
+ expect(n2.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Darwin!");
json.set(dm2, "lastName", "Brown");
hsp.refresh();
- expect(n1.node.firstChild.nodeValue).to.equal("Hello Daniel Kahneman!");
- expect(n2.node.firstChild.nodeValue).to.equal("Hello Charles Brown!");
+ expect(n1.node.firstChild.nodeValue.trim()).to.equal("Hello Daniel Kahneman!");
+ expect(n2.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Brown!");
n1.$dispose();
n2.$dispose();
});
@@ -146,15 +146,15 @@ describe("Text Nodes", function () {
var n2 = hello3(dm);
var n3 = hello4(dm);
- expect(n1.node.firstChild.nodeValue).to.equal("Hello Charles Darwin!");
- expect(n2.node.firstChild.nodeValue).to.equal("Hello Charles Darwin!");
- expect(n3.node.firstChild.nodeValue).to.equal("Hello Charles Darwin!");
+ expect(n1.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Darwin!");
+ expect(n2.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Darwin!");
+ expect(n3.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Darwin!");
json.set(dm, "lastName", "Brown");
hsp.refresh();
- expect(n1.node.firstChild.nodeValue).to.equal("Hello Charles Brown!");
- expect(n2.node.firstChild.nodeValue).to.equal("Hello Charles Brown!");
- expect(n3.node.firstChild.nodeValue).to.equal("Hello Charles Darwin!"); // unbound case
+ expect(n1.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Brown!");
+ expect(n2.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Brown!");
+ expect(n3.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Darwin!"); // unbound case
n1.$dispose();
n2.$dispose();
@@ -182,17 +182,17 @@ describe("Text Nodes", function () {
// check that generator is not impacted by the $dispose call
n = hello3(dm);
- expect(n.node.firstChild.nodeValue).to.equal("Hello Charles Darwin!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Darwin!");
json.set(dm, "lastName", "Brown");
hsp.refresh();
- expect(n.node.firstChild.nodeValue).to.equal("Hello Charles Brown!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Charles Brown!");
n.$dispose();
});
it("tests a template with a simple string parameter", function () {
var n = hello5("Bart");
- expect(n.node.firstChild.nodeValue).to.equal("Hello Bart!");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Hello Bart!");
n.$dispose();
});
@@ -200,7 +200,7 @@ describe("Text Nodes", function () {
globalValue = "blah blah";
var n = hello6();
- expect(n.node.firstChild.nodeValue).to.equal("blah blah");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("blah blah");
n.$dispose();
});
@@ -208,7 +208,7 @@ describe("Text Nodes", function () {
globalValueInt = 0;
var n = hello9();
- expect(n.node.firstChild.nodeValue).to.equal("0");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("0");
n.$dispose();
});
@@ -219,12 +219,12 @@ describe("Text Nodes", function () {
};
var n = hello7(d);
- expect(n.node.firstChild.nodeValue).to.equal("Omer-Simpson");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Omer-Simpson");
json.set(d, "firstName", "Marge");
hsp.refresh();
- expect(n.node.firstChild.nodeValue).to.equal("Marge-Simpson");
+ expect(n.node.firstChild.nodeValue.trim()).to.equal("Marge-Simpson");
n.$dispose();
});