Как запустить $ onInit или $ onChanges косвенно в модульном тестировании контроллера угловых компонентов?

Я использую Angular 1.5.5 и Jasmine в качестве тестовой среды. В настоящее время я должен сделать что-то вроде этого, чтобы тест прошел:

function createController(bindings) {
    return $componentController('myController', null, bindings);
}

beforeEach(inject(function (_$componentController_) {
    $componentController = _$componentController_;
}));

describe('on pages updated', function () {

    beforeEach(function () {
        controller = createController({prop1: 0, prop2: 0});
        controller.$onInit(); // you see I have to explitcitly call this $onInit function
    });

    it('should update isSelected and currentPage', function () {
        expect(controller.prop1).toBe(0);
        expect(controller.prop2).toBe(0);

        controller.prop1= 1;
        controller.prop2= 2;
        controller.$onChanges(controller); // and $onChanges here as well

        expect(controller.prop1).toBe(1);
        expect(controller.prop2).toBe(2);
    });

});

Ответы на вопрос(3)

Ваш ответ на вопрос