Skip to content

Commit

Permalink
add tests for updating the default insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Sep 29, 2017
1 parent cb518d1 commit 517f30d
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions test/core/component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,32 @@ describe("Component", function() {
});

describe("Insertion", function() {
it("should render the default insertion", function() {
var defaultInsertion = createTestElement("componentDefaultInsertion", "<component-default-insertion>Hello Moon!</component-default-insertion>");
Moon.extend("component-default-insertion", {
template: "<h1><m-insert></m-insert></h1>"
});

Moon.extend("component-default-insertion", {
template: "<h1><m-insert></m-insert></h1>"
});
var defaultInsertion = createTestElement("componentDefaultInsertion", "<component-default-insertion>{{msg}}</component-default-insertion>");

new Moon({
root: "#componentDefaultInsertion"
});
var app = new Moon({
root: "#componentDefaultInsertion",
data: {
msg: "Hello Moon!"
}
});

it("should render the default insertion", function() {
return wait(function() {
expect(defaultInsertion.firstChild.nodeName.toLowerCase()).to.equal("h1");
expect(defaultInsertion.firstChild.innerHTML).to.equal("Hello Moon!");
});
});

it("should update the default insertion", function() {

app.set("msg", "Changed");
return wait(function() {
expect(defaultInsertion.firstChild.nodeName.toLowerCase()).to.equal("h1");
expect(defaultInsertion.firstChild.innerHTML).to.equal("Changed");
});
});

// it("should render a named slot", function() {
Expand Down Expand Up @@ -360,7 +367,7 @@ describe("Component", function() {
button.click();

Moon.nextTick(function() {
expect(eventCalled).to.be['true'];
expect(eventCalled).to.be["true"];
expect(p.innerHTML).to.equal("1");
expect(h1.innerHTML).to.equal("1");

Expand Down

0 comments on commit 517f30d

Please sign in to comment.