Skip to content

Commit

Permalink
add extra test to confirm that existing content is removed when using…
Browse files Browse the repository at this point in the history
… template binding (without foreach, which was always working properly) in case there is refactoring in the future
  • Loading branch information
rniemeyer committed Sep 14, 2013
1 parent bf667a7 commit 29189fc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/templatingBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ describe('Templating', function() {
expect(testNode.childNodes[0].innerHTML).toEqual("template output");
});

it('Should remove existing content when rendering a template using data-bind syntax', function () {
ko.setTemplateEngine(new dummyTemplateEngine({ someTemplate: "template output" }));
testNode.innerHTML = "<div data-bind='template:\"someTemplate\"'><span>existing content</span></div>";
ko.applyBindings(null, testNode);
expect(testNode.childNodes[0].innerHTML).toEqual("template output");
});

it('Should be able to tell data-bind syntax which object to pass as data for the template (otherwise, uses viewModel)', function () {
ko.setTemplateEngine(new dummyTemplateEngine({ someTemplate: "result = [js: childProp]" }));
testNode.innerHTML = "<div data-bind='template: { name: \"someTemplate\", data: someProp }'></div>";
Expand Down

0 comments on commit 29189fc

Please sign in to comment.