Skip to content

Instantly share code, notes, and snippets.

@antonydenyer
Last active August 29, 2015 14:04
Show Gist options
  • Save antonydenyer/15da0436e69c88552d85 to your computer and use it in GitHub Desktop.
Save antonydenyer/15da0436e69c88552d85 to your computer and use it in GitHub Desktop.
describe('MyController', function () {
var controller, scope, myService, q;
beforeEach(function () { module('MyApp'); });
beforeEach(inject(function ($controller, $rootScope, $q) {
controller = $controller;
scope = $rootScope.$new();
myService = jasmine.createSpyObj('myService', ['getSomething']);
q = $q;
}));
describe('when returning promises', function () {
beforeEach(function () {
myService.getSomething.and.returnValue(q.when({ result: 'I Promise' }));
controller('MyController', { $scope: scope, myService: myService });
scope.$apply();
});
it('should set the response onto the viewModel', function () {
expect(scope.viewModel.result).toBe('I Promise');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment