Skip to content

Commit

Permalink
Add spec for component custom element
Browse files Browse the repository at this point in the history
  • Loading branch information
mbest committed Oct 18, 2017
1 parent b7decfd commit 785464f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/components/customElementBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,24 @@ describe('Components: Custom elements', function() {
+ '</li>'
);
});

it('Should call an afterRender callback function', function () {
ko.components.register('test-component', { template: 'custom element'});
testNode.innerHTML = '<test-component data-bind="afterRender: callback"></test-component>';

var callbacks = 0,
viewModel = {
callback: function (nodes, data) {
expect(nodes.length).toEqual(1);
expect(nodes[0]).toEqual(testNode.childNodes[0].childNodes[0]);
expect(data).toEqual(undefined);
callbacks++;
}
};
ko.applyBindings(viewModel, testNode);
expect(callbacks).toEqual(0);

jasmine.Clock.tick(1);
expect(testNode).toContainHtml('<test-component data-bind="afterrender: callback">custom element</test-component>');
});
});

0 comments on commit 785464f

Please sign in to comment.