Created
November 2, 2015 06:29
-
-
Save JeremyMorgan/2d2aa023b21a14c22970 to your computer and use it in GitHub Desktop.
controllerspec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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