ghidenon Stack Overflow • Recommends
On “To test a custom validation angularjs directive”
I figured it out by reading angular-app code https://github.com/angular-app/angular-app
This video also helps too link to this video
Two mistakes that I made:
Do not bind directly to the scope when you are doing ng-model
Use form controller to directly manipulate what to pass for directives
Here is the updated version. The directive is the same, only the test that I changed.
describe('directives', function() {
var $scope, form;
beforeEach(module('exampleDirective'));
beforeEach(inject(function($compile, $rootScope) {
$scope = $rootScope;
var element = angular.element(
'<form name="form">' +
'<input ng-model="model.somenum" name="somenum" integer />' +
'</form>'
);
$scope.model = {…