Following the guidance provided by Josh in a post reply on unit testing John Papa's vm.model with jasmine, I am still unable to display my controller values in the testing area. It seems like the issue lies with the data service, which is essential for our Single Page Application and follows John Papa's styling guidelines.
Below is a code snippet showcasing the code and the errors that I am encountering:
(function() {
'use strict';
angular.module('tickets')
.service("DataService", DataService)
/* @ngInject */
DataService.$inject = ["$rootScope", "$q"];
function DataService($rootScope, $q) {
var vm = this;
vm.nameDefault = "Name -- Please Authenticate";
vm.name = vm.nameDefault;
};
})();
(function() {
'use strict';
angular.module('tickets')
.controller('HomeController', HomeController);
/* @ngInject */
HomeController.$inject = ['$scope', '$location', 'DataService'];
function HomeController($scope, $location, DataService) {
var vm = this;
vm.name = DataService.name;
vm.nameDefault = DataService.nameDefault;
};
})();
When I use this code in our native environment, it validates that everything in the data service has been instantiated correctly. However, when using the styling from the aforementioned question, additional errors regarding scope instantiation arise, even though it mirrors the structure of that question.
I would expect a similar solution as the unanswered question on testing John papa vm.model controllers and factories with Jasmine.
Any assistance you can provide is greatly appreciated.
-C§
Edit Despite finding a solution, any feedback on why one implementation works over two others would be valuable. This setup uses Karma version 0.13.8, jasmine 2.1.0, and Angular 1.4.0.
While it may seem like a quick resolution, I have been struggling with this since Friday afternoon and have experimented with various formats without success.
Feel free to share your comments and insights so I can enhance my understanding, especially since I am relatively new to AngularJS (just a month in).
Thank you once again,
-C§