Hi everyone, I'm currently trying to test an angular controller and could
use some help setting up the tests.
var app = angular.module('contentDemo1', ['ngMaterial', 'ngMessages',
'ngMdIcons', 'ui.bootstrap', 'fixed.table.header']);
app.controller('AppCtrl', ['$scope', '$http', '$mdDialog', '$mdMedia',
function($scope, $http, $mdDialog, $mdMedia) {
There is the start of the controller, and here was my attempt at setting up
the tests after reading extensively online, but I am completely lost.
describe('AppCtrl', function() {
var $httpBackend, $rootScope, createController, $mdDialog, $mdMedia;
// Set up the module
beforeEach(module('contentDemo1'));
beforeEach(inject(function($injector) {
// Set up the mock http service responses
$httpBackend = $injector.get('$httpBackend');
$mdDialog = $injector.get('$mdDialog');
$mdMedia = $injector.get('$mdMedia');
// Get hold of a scope (i.e. the root scope)
$rootScope = $injector.get('$rootScope');
// The $controller service is used to create instances of controllers
var $controller = $injector.get('$controller');
createController = function() {
return $controller('AppCtrl', {'$scope' : $rootScope,
'$http':$httpBackend, '$mdDialog':$mdDialog, '$mdMedia':$mdMedia });
};
}));
afterEach(function() {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
Any help would be greatly appreciated. Thanks!
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.