javascript - How do I test view that uses controllerAs in AngularJS -
i'm trying test view of controller cannot work. when try simple template as<h1>test</h1> works when template using controlleras syntax expected undefined contain 'test'. did research , transcludecontrollers should deal don't. test this:
it('should show test section', () => { let candidatesctrl = $controller('candidatescontroller', mock); candidatesctrl.loading = false; let scope = $rootscope.$new(); let linkfn = $compile('<h1 ng-if="!candidatesctrl.loading">test</h1>'); let view = linkfn(scope, undefined, { transcludecontrollers: { candidatescontroller: { instance: candidatesctrl } } }); scope.$digest(); let templateashtml = view.html(); expect(templateashtml).tocontain('test'); }); how work? i'm using angularjs 1.6.3 , jasmine/karma combo.
Comments
Post a Comment