Cordova & AngularJS unit testing -
i'm developing application based on cordova (http://cordova.apache.org), deployed on ios now.
i've started write unit tests using jasmine, used when developed browser application angularjs (using jasmine).
var custom_matchers = { tobeafunction: function () { var actual = this.actual; var nottext = this.isnot ? " not" : ""; this.message = function() { return "expected " + actual.constructor.name + nottext + " function"; }; return angular.isfunction(actual); } } describe("test using aboutusctrl", function () { var $controller, $scope; beforeeach(function () { module("app"); inject(function ($rootscope, _$controller_) { $scope = $rootscope.$new(); $controller = _$controller_; }); this.addmatchers(custom_matchers); }) describe(", creating controller", function () { var controller; beforeeach(function () { controller = $controller("aboutusctrl", {$scope: $scope}); }); it("should have 'deleteaccount' function", function () { expect($scope.deleteaccount).tobedefined(); expect($scope.deleteaccount).tobeafunction(); }); it("should have 'gonext' function", function () { expect($scope.gonext).tobedefined(); expect($scope.gonext).tobeafunction(); }) }); }) when execute piece of code, error, thrown cordova: function required first argument!. quick research makes me realize cordova told subscribe array of functions (channel.subscribe) instead of function. note error not happen if remove each test.
is result of i've been doing wrong ?
before ask, here karma config file: http://pastebin.com/jzmgghpn
my problem complicated go through, since there's not lot of stuff unit testing case. basically, including cordova.js in karma runner, because 1 of js files needed it. figured out js file (pushnotification.js) didn't need included right here, solving problem.
Comments
Post a Comment