@@ -21,80 +21,80 @@ assert.strictEqual(
21
21
typeof ServerResponse . prototype . _implicitHeader , 'function' ) ;
22
22
23
23
// validateHeader
24
- assert . throws ( ( ) => {
24
+ common . expectsError ( ( ) => {
25
25
const outgoingMessage = new OutgoingMessage ( ) ;
26
26
outgoingMessage . setHeader ( ) ;
27
- } , common . expectsError ( {
27
+ } , {
28
28
code : 'ERR_INVALID_HTTP_TOKEN' ,
29
29
type : TypeError ,
30
30
message : 'Header name must be a valid HTTP token ["undefined"]'
31
- } ) ) ;
31
+ } ) ;
32
32
33
- assert . throws ( ( ) => {
33
+ common . expectsError ( ( ) => {
34
34
const outgoingMessage = new OutgoingMessage ( ) ;
35
35
outgoingMessage . setHeader ( 'test' ) ;
36
- } , common . expectsError ( {
36
+ } , {
37
37
code : 'ERR_MISSING_ARGS' ,
38
38
type : TypeError ,
39
39
message : 'The "value" argument must be specified'
40
- } ) ) ;
40
+ } ) ;
41
41
42
- assert . throws ( ( ) => {
42
+ common . expectsError ( ( ) => {
43
43
const outgoingMessage = new OutgoingMessage ( ) ;
44
44
outgoingMessage . setHeader ( 404 ) ;
45
- } , common . expectsError ( {
45
+ } , {
46
46
code : 'ERR_INVALID_HTTP_TOKEN' ,
47
47
type : TypeError ,
48
48
message : 'Header name must be a valid HTTP token ["404"]'
49
- } ) ) ;
49
+ } ) ;
50
50
51
- assert . throws ( ( ) => {
51
+ common . expectsError ( ( ) => {
52
52
const outgoingMessage = new OutgoingMessage ( ) ;
53
53
outgoingMessage . setHeader . call ( { _header : 'test' } , 'test' , 'value' ) ;
54
- } , common . expectsError ( {
54
+ } , {
55
55
code : 'ERR_HTTP_HEADERS_SENT' ,
56
56
type : Error ,
57
57
message : 'Cannot set headers after they are sent to the client'
58
- } ) ) ;
58
+ } ) ;
59
59
60
- assert . throws ( ( ) => {
60
+ common . expectsError ( ( ) => {
61
61
const outgoingMessage = new OutgoingMessage ( ) ;
62
62
outgoingMessage . setHeader ( '200' , 'あ' ) ;
63
- } , common . expectsError ( {
63
+ } , {
64
64
code : 'ERR_INVALID_CHAR' ,
65
65
type : TypeError ,
66
66
message : 'Invalid character in header content ["200"]'
67
- } ) ) ;
67
+ } ) ;
68
68
69
69
// write
70
- assert . throws ( ( ) => {
70
+ common . expectsError ( ( ) => {
71
71
const outgoingMessage = new OutgoingMessage ( ) ;
72
72
outgoingMessage . write ( ) ;
73
- } , common . expectsError ( {
73
+ } , {
74
74
code : 'ERR_METHOD_NOT_IMPLEMENTED' ,
75
75
type : Error ,
76
76
message : 'The _implicitHeader() method is not implemented'
77
- } ) ) ;
77
+ } ) ;
78
78
79
79
assert ( OutgoingMessage . prototype . write . call ( { _header : 'test' } ) ) ;
80
80
81
- assert . throws ( ( ) => {
81
+ common . expectsError ( ( ) => {
82
82
const outgoingMessage = new OutgoingMessage ( ) ;
83
83
outgoingMessage . write . call ( { _header : 'test' , _hasBody : 'test' } ) ;
84
- } , common . expectsError ( {
84
+ } , {
85
85
code : 'ERR_INVALID_ARG_TYPE' ,
86
86
type : TypeError ,
87
87
message : 'The first argument must be one of type string or Buffer'
88
- } ) ) ;
88
+ } ) ;
89
89
90
- assert . throws ( ( ) => {
90
+ common . expectsError ( ( ) => {
91
91
const outgoingMessage = new OutgoingMessage ( ) ;
92
92
outgoingMessage . write . call ( { _header : 'test' , _hasBody : 'test' } , 1 ) ;
93
- } , common . expectsError ( {
93
+ } , {
94
94
code : 'ERR_INVALID_ARG_TYPE' ,
95
95
type : TypeError ,
96
96
message : 'The first argument must be one of type string or Buffer'
97
- } ) ) ;
97
+ } ) ;
98
98
99
99
// addTrailers()
100
100
// The `Error` comes from the JavaScript engine so confirm that it is a
@@ -105,20 +105,20 @@ assert.throws(() => {
105
105
outgoingMessage . addTrailers ( ) ;
106
106
} , TypeError ) ;
107
107
108
- assert . throws ( ( ) => {
108
+ common . expectsError ( ( ) => {
109
109
const outgoingMessage = new OutgoingMessage ( ) ;
110
110
outgoingMessage . addTrailers ( { 'あ' : 'value' } ) ;
111
- } , common . expectsError ( {
111
+ } , {
112
112
code : 'ERR_INVALID_HTTP_TOKEN' ,
113
113
type : TypeError ,
114
114
message : 'Trailer name must be a valid HTTP token ["あ"]'
115
- } ) ) ;
115
+ } ) ;
116
116
117
- assert . throws ( ( ) => {
117
+ common . expectsError ( ( ) => {
118
118
const outgoingMessage = new OutgoingMessage ( ) ;
119
119
outgoingMessage . addTrailers ( { 404 : 'あ' } ) ;
120
- } , common . expectsError ( {
120
+ } , {
121
121
code : 'ERR_INVALID_CHAR' ,
122
122
type : TypeError ,
123
123
message : 'Invalid character in trailer content ["404"]'
124
- } ) ) ;
124
+ } ) ;
0 commit comments