Hey, I need help with my testing service.
I have this service: MyService.js
And this controller:
angular.module('MyControllers', [])
.controller('MyCtrl2', ['$scope', 'FnEncode', function ($scope, FnEncode) {
$scope.encoded1 = "";
$scope.encoded2 = "";
$scope.encoded3 = "";
$scope.encode1 = function() {
$scope.encoded1 = FnEncode.encodeUUI(FnEncode.encodeFunctionalNumber($scope.numberToEncode));
};
$scope.encode2 = function() {
$scope.encoded2 = FnEncode.encodeUUI(FnEncode.encodeFunctionalNumber($scope.numberToEncode)+
FnEncode.encode2($scope.EncodeWith2));
};
$scope.encode3 = function() {
$scope.encoded3 = FnEncode.encodeUUI(FnEncode.encodeFunctionalNumber($scope.numberToEncode)+
FnEncode.encode3($scope.EncodeWith3));
};
}]);
The service is basically doing when I enter 123 in a text field it outputs me 00050221F3, where the first 00 are encodeUUI. I did test something like this but it says Cannot read property encoded1:
'use strict';
describe('My services', function() {
beforeEach(module('myApp'));
beforeEach(module('MyServices'));
describe('MyCtrl2', function() {
var scope, ctrl;
beforeEach(inject(function($rootScope, $controller) {
scope = $rootScope.$new();
ctrl = $controller('MyCtrl2', {$scope: scope});
}));
it('should output: ', function(scope) {
expect(scope.encoded1.toBe("00050221F3"));
});
});
});
I hope somebody can tell me where I am doing wrong?