File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,40 @@ describe('WebSocket', function() {
49
49
done ( ) ;
50
50
}
51
51
} ) ;
52
+
53
+ it ( 'should emit an error object when the receiver throws an error string' , function ( done ) {
54
+
55
+ var wss = new WebSocketServer ( { port : ++ port } , function ( ) {
56
+
57
+ var ws = new WebSocket ( 'ws://localhost:' + port ) ;
58
+
59
+ ws . on ( 'open' , function ( ) {
60
+ ws . _receiver . error ( 'This is an error string' , 1002 ) ;
61
+ } ) ;
62
+
63
+ ws . on ( 'error' , function ( error ) {
64
+ error . should . be . an . instanceof ( Error ) ;
65
+ done ( ) ;
66
+ } ) ;
67
+ } ) ;
68
+ } ) ;
69
+
70
+ it ( 'should emit an error object when the receiver throws an error object' , function ( done ) {
71
+
72
+ var wss = new WebSocketServer ( { port : ++ port } , function ( ) {
73
+
74
+ var ws = new WebSocket ( 'ws://localhost:' + port ) ;
75
+
76
+ ws . on ( 'open' , function ( ) {
77
+ ws . _receiver . error ( new Error ( 'This is an error object' ) , 1002 ) ;
78
+ } ) ;
79
+
80
+ ws . on ( 'error' , function ( error ) {
81
+ error . should . be . an . instanceof ( Error ) ;
82
+ done ( ) ;
83
+ } ) ;
84
+ } ) ;
85
+ } ) ;
52
86
} ) ;
53
87
54
88
describe ( 'options' , function ( ) {
You can’t perform that action at this time.
0 commit comments