@@ -31,7 +31,7 @@ describe('WebSocket', function () {
31
31
} ) ;
32
32
33
33
describe ( 'options' , function ( ) {
34
- it ( 'should accept an `agent` option' , function ( done ) {
34
+ it ( 'accepts an `agent` option' , function ( done ) {
35
35
const agent = new CustomAgent ( ) ;
36
36
37
37
agent . addRequest = ( ) => {
@@ -41,11 +41,18 @@ describe('WebSocket', function () {
41
41
const ws = new WebSocket ( 'ws://localhost' , { agent } ) ;
42
42
} ) ;
43
43
44
- // GH-227
45
- it ( 'should accept the `options` object as the 3rd argument' , function ( ) {
46
- const ws = new WebSocket ( 'ws://localhost' , [ ] , {
47
- agent : new CustomAgent ( )
48
- } ) ;
44
+ it ( 'accepts the `options` object as the 3rd argument' , function ( ) {
45
+ const agent = new CustomAgent ( ) ;
46
+ let count = 0 ;
47
+ let ws ;
48
+
49
+ agent . addRequest = ( req ) => count ++ ;
50
+
51
+ ws = new WebSocket ( 'ws://localhost' , undefined , { agent } ) ;
52
+ ws = new WebSocket ( 'ws://localhost' , null , { agent } ) ;
53
+ ws = new WebSocket ( 'ws://localhost' , [ ] , { agent } ) ;
54
+
55
+ assert . strictEqual ( count , 3 ) ;
49
56
} ) ;
50
57
51
58
it ( 'throws an error when using an invalid `protocolVersion`' , function ( ) {
@@ -57,7 +64,7 @@ describe('WebSocket', function () {
57
64
) ;
58
65
} ) ;
59
66
60
- it ( 'should accept the localAddress option' , function ( done ) {
67
+ it ( 'accepts the localAddress option' , function ( done ) {
61
68
//
62
69
// Skip this test on macOS as by default all loopback addresses other
63
70
// than 127.0.0.1 are disabled.
@@ -76,14 +83,14 @@ describe('WebSocket', function () {
76
83
} ) ;
77
84
} ) ;
78
85
79
- it ( 'should accept the localAddress option whether it was wrong interface' , function ( ) {
86
+ it ( 'accepts the localAddress option whether it was wrong interface' , function ( ) {
80
87
assert . throws (
81
88
( ) => new WebSocket ( `ws://localhost:${ port } ` , { localAddress : '123.456.789.428' } ) ,
82
89
/ m u s t b e a v a l i d I P : 1 2 3 .4 5 6 .7 8 9 .4 2 8 /
83
90
) ;
84
91
} ) ;
85
92
86
- it ( 'should accept the family option' , function ( done ) {
93
+ it ( 'accepts the family option' , function ( done ) {
87
94
const wss = new WebSocketServer ( { host : '::1' , port : ++ port } , ( ) => {
88
95
const ws = new WebSocket ( `ws://localhost:${ port } ` , { family : 6 } ) ;
89
96
} ) ;
0 commit comments