I use John papa angular style guide my controller looks like:
following the style John papa style controller style guide:
function testController() {
var vm = this;
vm.model = { name: "controllerAs vm test" };
}
My testing code looks like:
describe('Controller: testController', function () {
beforeEach(module('myApp'));
var testController;
beforeEach(inject(function ($controller) {
scope = {};
testController = $controller('testController', {
});
}));
it('should have vm.model defined and testController.vm.model is equal to controllerAs vm test', function () {
expect(testController.vm).toBeDefined();
expect(testController.vm.model).toBeDefined();
expect(testController.vm.model.name).toEqual("controllerAs vm test");
});
});
Result:
Test failed: Result Message: Expected undefined to be defined. at stack
So my question is how can we test vm.model and other variables from this? I have not found proper guide line in the guide lines: controllers