diff --git a/test/oauth2.spec.js b/test/oauth2.spec.js index 69df04c3..9ec7d073 100644 --- a/test/oauth2.spec.js +++ b/test/oauth2.spec.js @@ -20,6 +20,24 @@ describe('SatellizerOauth2', function() { //this.oauth2.open(); }); + it('should propagate promise rejections', inject(function($q, SatellizerPopup) { + var error; + var message = 'Popup Rejected'; + var defer = $q.defer(); + + spyOn(SatellizerPopup, 'pollPopup').and.returnValue(defer.promise); + + this.oauth2.open(this.config.providers.github).catch(function (err) { + error = err; + }); + + defer.reject(message); + this.$timeout.flush(); + this.$timeout.verifyNoPendingTasks(); + + expect(error).toEqual(message); + })); + }); describe('exchangeForToken()', function() {