Skip to content

Commit f2aad66

Browse files
committed
Merge pull request #827 from stackus/add-test-for-pr-784
Add test for Popup promise rejections (PR #784)
2 parents d39d530 + 0883408 commit f2aad66

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/oauth2.spec.js

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ describe('SatellizerOauth2', function() {
2020
//this.oauth2.open();
2121
});
2222

23+
it('should propagate promise rejections', inject(function($q, SatellizerPopup) {
24+
var error;
25+
var message = 'Popup Rejected';
26+
var defer = $q.defer();
27+
28+
spyOn(SatellizerPopup, 'pollPopup').and.returnValue(defer.promise);
29+
30+
this.oauth2.open(this.config.providers.github).catch(function (err) {
31+
error = err;
32+
});
33+
34+
defer.reject(message);
35+
this.$timeout.flush();
36+
this.$timeout.verifyNoPendingTasks();
37+
38+
expect(error).toEqual(message);
39+
}));
40+
2341
});
2442

2543
describe('exchangeForToken()', function() {

0 commit comments

Comments
 (0)