I am trying to test my AngularJS controller function using Jasmine. However, I am getting TypeError: undefined is not a function.
This is what the test looks like:
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);
});
});
And here's the function I am trying to test:
$scope.toggleCreateActive = function(category) {
category.create_active = !category.create_active;
}
What am I doing wrong?