From 2523baecdb30e9049de2551c5001a78c6f063656 Mon Sep 17 00:00:00 2001 From: Ben Quarmby Date: Tue, 27 Jan 2015 22:36:27 +1100 Subject: [PATCH] Custom injection specs. --- source/kontainer-spec.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/source/kontainer-spec.js b/source/kontainer-spec.js index 15d0dcf..bae87bb 100644 --- a/source/kontainer-spec.js +++ b/source/kontainer-spec.js @@ -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); }); @@ -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();