Skip to content

Instantly share code, notes, and snippets.

@lewiscowper
Created July 6, 2015 21:41
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 lewiscowper/b53a7547f60259f2a57a to your computer and use it in GitHub Desktop.
Save lewiscowper/b53a7547f60259f2a57a to your computer and use it in GitHub Desktop.
describe('when the bar function is called', function () {
beforeEach(function () {
_scope.bar();
});
it('should have called the foo function from the service', function () {
expect(service.foo).toHaveBeenCalled();
});
describe('when the foo promise resolves', function () {
beforeEach(function () {
service.deferredFoo.resolve();
_scope.$digest();
});
it('should set the qux variable correctly', function () {
expect(_scope.qux).toBe(true);
});
});
describe('when the foo promise rejects', function () {
beforeEach(function () {
service.deferredFoo.reject();
_scope.$digest();
});
it('should set the qux variable correctly', function () {
expect(_scope.qux).toBeUndefined();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment