【发布时间】:2014-05-27 18:13:58
【问题描述】:
我正在尝试使用Jasmine 测试我的AngularJS 控制器功能。但是,我收到了TypeError: undefined is not a function。
这是测试的样子:
describe('BoardController', function() {
beforeEach(module('examtesting'));
var BoardController;
beforeEach(inject(function($rootScope, $controller) {
var scope = $rootScope.$new();
BoardController = $controller('BoardController', {
$scope: scope,
board: null,
BoardService: null
});
}));
it ("should toggle create_active", function() {
var category = { create_active: false }
BoardController.toggleCreateActive(category);
expect(category.create_active).toBe(true);
});
});
这是我要测试的功能:
$scope.toggleCreateActive = function(category) {
category.create_active = !category.create_active;
}
我做错了什么?
【问题讨论】:
标签: javascript angularjs unit-testing testing jasmine