mardi 5 avril 2016

How to write test case for Custom Directive with link function?

I am new to unit testing and I have to write the unit test for custom directive.

My Directive code is here:

(function () {
    angular.module('uspCustomDirectives', []).directive('convertToInt', function () {
        return {
            require: 'ngModel',
            restrict: 'A',
            link: function (scope, element, attributes, ngModelController) {
                ngModelController.$parsers.push(function (val) {
                    return '' + val;
                });
                ngModelController.$formatters.push(function (val) {
                    return parseInt(val, 10);
                });
            }
        };
    });
}());

Please help me out to write the test case for this. I am not able to write.....

Aucun commentaire:

Enregistrer un commentaire