Skip to content

Commit

Permalink
Custom injection specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
benquarmby committed Jan 28, 2015
1 parent c729041 commit 2523bae
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion source/kontainer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
beforeEach(function () {
jasmine.clock().install();
element = document.createElement('div');
element.setAttribute('data-bind', 'component: \'fake-component\'');
element.setAttribute('data-bind', 'component: { name: \'fake-component\', params: \'params\' }');
document.body.appendChild(element);
});

Expand All @@ -97,6 +97,30 @@
expect(element.firstChild.innerHTML).toBe('injected value');
});

it('should inject componentInfo', function () {
var actualElement;

registerComponent(['componentInfo', function (componentInfo) {
actualElement = componentInfo.element;
}]);

ko.applyBindings(null, element);
jasmine.clock().tick(1);
expect(actualElement).toBe(element);
});

it('should inject params', function () {
var actualParams;

registerComponent(['params', function (params) {
actualParams = params;
}]);

ko.applyBindings(null, element);
jasmine.clock().tick(1);
expect(actualParams).toBe('params');
});

it('should only invoke factories once', function () {
var factory1 = jasmine.createSpy(),
factory2 = jasmine.createSpy();
Expand Down

0 comments on commit 2523bae

Please sign in to comment.