mardi 12 avril 2016

How to write the test case for Controller?

I am new to unit test.

Please help me to write test case code for following code:

 $scope.convertToInt = function (str) {
                if (!isNumberEmpty(str) && !isNaN(str)) {
                    return parseInt(str, 10);
                }
                return "";
            }

I have tried like this, but not able to do.

describe('ConfigurationTestController', function() {

  beforeEach(module('usp.configuration')); 

  describe('ConfigurationController', function () {
        beforeEach(inject(function ($rootScope, $controller) {
            scope = $rootScope.$new();
            controller = $controller('ConfigurationController', {
                '$scope': scope
            });
        }));
    });
});

Please tell me how can I write.......

Aucun commentaire:

Enregistrer un commentaire