Jasmine이있는 구성 요소에 대해 1.5.6 단위 테스트를 수행하려고합니다. 그러나 나는 아래의 오류를 계속 받고 이유를 모르고있다.
오류 : 미정은 ('controller.name'를 평가) 목적 아니다
성분 :
function MainViewerCtrl() {
this.$onInit = function(){
console.log('Component main viewer initialized!');
};
this.name = 'Main Component!';
}
angular.module('ks').component('mainViewer', {
bindings: {
name : '@'
},
controller : MainViewerCtrl,
templateUrl: "mainViewer.html"
});
규격 :
describe('Component : mainViewer', function(){
beforeEach(angular.mock.module('ks'));
describe('with $componentController', function() {
var controller, scope;
beforeEach(inject(function($rootScope, $componentController){
scope = $rootScope.$new();
controller = $componentController('mainViewer',
{$scope:scope},
{name: 'Main Component!'});
}));
it('should have my binding bound', function() {
expect(controller.name).toBeDefined();
expect(controller.name).toBe('Main Component!');
});
});
});
내가 뭘 잘못하고 있니?
당신은 이것을 할 필요가 없습니다 ...'_ $ componentController_'의 밑줄은 당신이 그것을 주입 할 수 있고'$ componentController'라는 변수 이름을 사용하지 못하게하는 관례입니다. $ componentController가 나 자신을 정의하지 못하게되었습니다. – gonzofish