【发布时间】:2014-12-27 10:09:25
【问题描述】:
我有一个构建这种 html 的简单指令:
<div class='snapshots-feeds-toggle-box'>
<button ui-sref='feeds' class='state-toggle-btn' ui-sref-active='active-state'>Feeds</button>
<button ui-sref='snapshots' class='state-toggle-btn' ui-sref-active='active-state'>Snapshots</button>
</div>
我想对它(karma+jasmine)进行单元测试,如下所示:
我只想检查我是否设置了提要状态,按钮是否处于“活动状态”,我应该如何处理:
变量作用域,编译;
beforeEach(module('feedsSnapshotsApp'));
beforeEach(module('directives'));
beforeEach(inject(function ($rootScope,$compile) {
scope = $rootScope.$new();
compile = $compile;
...
scope.state = 'feeds' //?
it('should check if state is active',function(){
//What is the check that i can do here?
})
【问题讨论】:
标签: angularjs unit-testing jasmine karma-runner