-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for checking connection status (#662)
* Add support for checking connection status * update example * Update example * Remove unused import
- Loading branch information
1 parent
9b44014
commit 0d83e5d
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,6 +455,60 @@ describe('ConnectionsManager', function() { | |
}); | ||
}); | ||
|
||
describe('#checkStatus', function() { | ||
var params = { id: 5 }; | ||
var data = { | ||
id: params.id, | ||
name: 'Test connection' | ||
}; | ||
|
||
beforeEach(function() { | ||
this.request = nock(API_URL) | ||
.get('/connections/' + data.id + '/status') | ||
.reply(200); | ||
}); | ||
|
||
it('should accept a callback', function(done) { | ||
this.connections.checkStatus(params, function() { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should return a promise if no callback is given', function(done) { | ||
this.connections | ||
.checkStatus(params) | ||
.then(done.bind(null, null)) | ||
.catch(done.bind(null, null)); | ||
}); | ||
|
||
it('should report success', function(done) { | ||
nock.cleanAll(); | ||
|
||
var request = nock(API_URL) | ||
.get('/connections/' + params.id + '/status') | ||
.reply(200); | ||
|
||
this.connections.checkStatus(params).then(function(response) { | ||
expect(response).to.exist; | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should report failure', function(done) { | ||
nock.cleanAll(); | ||
|
||
var request = nock(API_URL) | ||
.get('/connections/' + params.id + '/status') | ||
.reply(500); | ||
|
||
this.connections.checkStatus(params).catch(function(err) { | ||
expect(err).to.exist; | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#delete user', function() { | ||
var id = 5; | ||
var email = '[email protected]'; | ||
|