-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ws): when connected failed, it have not trigger a error event
- Loading branch information
soliury
committed
Apr 13, 2021
1 parent
4ada37e
commit b38c399
Showing
4 changed files
with
31 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const assert = require('assert'); | ||
|
||
import Provider from '../../../src/viteAPI/provider'; | ||
import WS_RPC from '../../../src/WS'; | ||
|
||
describe('test ws provider', () => { | ||
it('should trigger event when connect successfully', (done) => { | ||
const wsServer = new WS_RPC('wss://node-tokyo.vite.net/ws', 2000, { | ||
retryInterval: 1, | ||
retryTimes: -1 | ||
}); | ||
const viteClient = new Provider(wsServer, () => { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should trigger error event when connected failed', (done) => { | ||
const wsServer = new WS_RPC('wss://no.vite.net/ws', 2000, { | ||
retryInterval: 1, | ||
retryTimes: -1 | ||
}); | ||
wsServer.on('error', (err) => { | ||
done(); | ||
}); | ||
}); | ||
}); |