GeezerVison is showing github.com — test: check arg type for dnsPromises.resolve · nodejs/node@9d85a05
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-dns.js +25-8Lines changed: 25 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -135,14 +135,31 @@ assert.deepStrictEqual(dns.getServers(), portsExpected); |
135 | 135 | dns.setServers([]); |
136 | 136 | assert.deepStrictEqual(dns.getServers(), []); |
137 | 137 |
|
138 | | -common.expectsError(() => { |
139 | | - dns.resolve('example.com', [], common.mustNotCall()); |
140 | | -}, { |
141 | | - code: 'ERR_INVALID_ARG_TYPE', |
142 | | - type: TypeError, |
143 | | - message: 'The "rrtype" argument must be of type string. ' + |
144 | | - 'Received type object' |
145 | | -}); |
| 138 | +{ |
| 139 | + const errObj = { |
| 140 | + code: 'ERR_INVALID_ARG_TYPE', |
| 141 | + type: TypeError, |
| 142 | + message: 'The "rrtype" argument must be of type string. ' + |
| 143 | + 'Received type object' |
| 144 | + }; |
| 145 | + common.expectsError(() => { |
| 146 | + dns.resolve('example.com', [], common.mustNotCall()); |
| 147 | + }, errObj); |
| 148 | + common.expectsError(() => { |
| 149 | + dnsPromises.resolve('example.com', []); |
| 150 | + }, errObj); |
| 151 | +} |
| 152 | +{ |
| 153 | + const errObj = { |
| 154 | + code: 'ERR_INVALID_ARG_TYPE', |
| 155 | + type: TypeError, |
| 156 | + message: 'The "name" argument must be of type string. ' + |
| 157 | + 'Received type undefined' |
| 158 | + }; |
| 159 | + common.expectsError(() => { |
| 160 | + dnsPromises.resolve(); |
| 161 | + }, errObj); |
| 162 | +} |
146 | 163 |
|
147 | 164 | // dns.lookup should accept only falsey and string values |
148 | 165 | { |
|