Skip to content

Instantly share code, notes, and snippets.

@JeremyMorgan
Created November 2, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyMorgan/2d2aa023b21a14c22970 to your computer and use it in GitHub Desktop.
Save JeremyMorgan/2d2aa023b21a14c22970 to your computer and use it in GitHub Desktop.
controllerspec.js
describe('homeController', function () {
beforeEach(module('revokinatorApp'));
beforeEach(module('Revokinator.Home.Controller'));
var $controller;
beforeEach(inject(function (_$controller_) {
// The injector unwraps the underscores (_) from around the parameter names when matching
$controller = _$controller_;
}));
describe('Initial Load', function () {
it('Default controller properties should load as expected', function () {
var CONFIG = { DebugMode: true, MockMode: false, StepCounter: 0 };
var $scope = {};
var controller = $controller('homeController', { $scope: $scope, CONFIG: CONFIG });
console.log(JSON.stringify(controller));
expect(controller.DebugMode).toEqual(true);
expect(controller.MockMode).toEqual(false);
expect(controller.StepCounter).toEqual(0);
});
it('Injected property values should persist', function () {
var CONFIG = { DebugMode: false, MockMode: true, StepCounter: 10 };
var $scope = {};
var controller = $controller('homeController', { $scope: $scope, CONFIG: CONFIG });
console.log(JSON.stringify(controller));
expect(controller.DebugMode).toEqual(false);
expect(controller.MockMode).toEqual(true);
expect(controller.StepCounter).toEqual(10);
});
});
describe('Consumer Service', function () {
it('Default controller properties should load as expected', function () {
var CONFIG = { DebugMode: true, MockMode: false, StepCounter: 0 };
var $scope = {};
var controller = $controller('homeController', { $scope: $scope, CONFIG: CONFIG });
console.log(JSON.stringify(controller));
expect(controller.DebugMode).toEqual(true);
expect(controller.MockMode).toEqual(false);
expect(controller.StepCounter).toEqual(0);
});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment