mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
[FIX] fix connection error handling
if connection to server can't be established, reject Promise of `connect()` method caller, instead of throwing error event on base object.
This commit is contained in:
@@ -106,6 +106,26 @@ describe('Connection', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw NotConnectedError if server not responding ', function(
|
||||
done
|
||||
) {
|
||||
if (process.browser) {
|
||||
const phantomTest = /PhantomJS/;
|
||||
if (phantomTest.test(navigator.userAgent)) {
|
||||
// inside PhantomJS this one just hangs, so skip as not very relevant
|
||||
done();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const connection = new utils.common.Connection('ws://127.0.0.1:321');
|
||||
connection.on('error', done);
|
||||
connection.connect().catch(error => {
|
||||
assert(error instanceof this.api.errors.NotConnectedError);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('DisconnectedError', function() {
|
||||
this.api.connection._send(JSON.stringify({
|
||||
command: 'config',
|
||||
|
||||
Reference in New Issue
Block a user