I have been learning AngularJS and things have been going pretty smoothly regarding unit testing, but I\'ve reached a bit of a tricky spot.
Suppose I have a simple f
Here's a way to unit test with an angular form without having to compile a controller's template. Works well for me in my limited usage.
describe('Test', function() {
var $scope, fooController;
beforeEach(function($rootScope, $controller, formDirective) {
$scope = $rootScope.$new();
fooController = $controller('fooController', {$scope: $scope});
// we manually create the form controller
fooController.form = $controller(formDirective[0].controller, {
$scope: $scope,
$element: angular.element(""),
$attrs: {}
});
});
it('should test something', function() {
expect(fooController.form.$valid).toBeFalsy();
});
});