| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,16 +68,16 @@ const goog = [ | |||
| 68 | 68 | ]; | |
| 69 | 69 | assert.doesNotThrow(() => dns.setServers(goog)); | |
| 70 | 70 | assert.deepStrictEqual(dns.getServers(), goog); | |
| 71 | - assert.throws(() => dns.setServers(['foobar']), common.expectsError({ | ||
| 71 | + common.expectsError(() => dns.setServers(['foobar']), { | ||
| 72 | 72 | code: 'ERR_INVALID_IP_ADDRESS', | |
| 73 | 73 | type: Error, | |
| 74 | 74 | message: 'Invalid IP address: foobar' | |
| 75 | - })); | ||
| 76 | - assert.throws(() => dns.setServers(['127.0.0.1:va']), common.expectsError({ | ||
| 75 | + }); | ||
| 76 | + common.expectsError(() => dns.setServers(['127.0.0.1:va']), { | ||
| 77 | 77 | code: 'ERR_INVALID_IP_ADDRESS', | |
| 78 | 78 | type: Error, | |
| 79 | 79 | message: 'Invalid IP address: 127.0.0.1:va' | |
| 80 | - })); | ||
| 80 | + }); | ||
| 81 | 81 | assert.deepStrictEqual(dns.getServers(), goog); | |
| 82 | 82 | ||
| 83 | 83 | const goog6 = [ | |
@@ -109,14 +109,14 @@ assert.deepStrictEqual(dns.getServers(), portsExpected); | |||
| 109 | 109 | assert.doesNotThrow(() => dns.setServers([])); | |
| 110 | 110 | assert.deepStrictEqual(dns.getServers(), []); | |
| 111 | 111 | ||
| 112 | - assert.throws(() => { | ||
| 112 | + common.expectsError(() => { | ||
| 113 | 113 | dns.resolve('example.com', [], common.mustNotCall()); | |
| 114 | - }, common.expectsError({ | ||
| 114 | + }, { | ||
| 115 | 115 | code: 'ERR_INVALID_ARG_TYPE', | |
| 116 | 116 | type: TypeError, | |
| 117 | 117 | message: 'The "rrtype" argument must be of type string. ' + | |
| 118 | 118 | 'Received type object' | |
| 119 | - })); | ||
| 119 | + }); | ||
| 120 | 120 | ||
| 121 | 121 | // dns.lookup should accept only falsey and string values | |
| 122 | 122 | { | |
@@ -167,24 +167,24 @@ assert.throws(() => { | |||
| 167 | 167 | * - it's an odd number different than 1, and thus is invalid, because | |
| 168 | 168 | * flags are either === 1 or even. | |
| 169 | 169 | */ | |
| 170 | - assert.throws(() => { | ||
| 170 | + common.expectsError(() => { | ||
| 171 | 171 | dns.lookup('nodejs.org', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 }, | |
| 172 | 172 | common.mustNotCall()); | |
| 173 | - }, common.expectsError({ | ||
| 173 | + }, { | ||
| 174 | 174 | code: 'ERR_INVALID_OPT_VALUE', | |
| 175 | 175 | type: TypeError, | |
| 176 | 176 | message: /The value "\d+" is invalid for option "hints"/ | |
| 177 | - })); | ||
| 177 | + }); | ||
| 178 | 178 | ||
| 179 | - assert.throws(() => dns.lookup('nodejs.org'), common.expectsError({ | ||
| 179 | + common.expectsError(() => dns.lookup('nodejs.org'), { | ||
| 180 | 180 | code: 'ERR_INVALID_CALLBACK', | |
| 181 | 181 | type: TypeError | |
| 182 | - })); | ||
| 182 | + }); | ||
| 183 | 183 | ||
| 184 | - assert.throws(() => dns.lookup('nodejs.org', 4), common.expectsError({ | ||
| 184 | + common.expectsError(() => dns.lookup('nodejs.org', 4), { | ||
| 185 | 185 | code: 'ERR_INVALID_CALLBACK', | |
| 186 | 186 | type: TypeError | |
| 187 | - })); | ||
| 187 | + }); | ||
| 188 | 188 | ||
| 189 | 189 | assert.doesNotThrow(() => dns.lookup('', { family: 4, hints: 0 }, | |
| 190 | 190 | common.mustCall())); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,9 +225,9 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) { | |||
| 225 | 225 | fs.symlinkSync(t[1], t[0], 'dir'); | |
| 226 | 226 | unlink.push(t[0]); | |
| 227 | 227 | }); | |
| 228 | - assert.throws(() => { | ||
| 228 | + common.expectsError(() => { | ||
| 229 | 229 | realpathSync(entry); | |
| 230 | - }, common.expectsError({ code: 'ELOOP', type: Error })); | ||
| 230 | + }, { code: 'ELOOP', type: Error }); | ||
| 231 | 231 | asynctest( | |
| 232 | 232 | realpath, [entry], callback, common.mustCall(function(err, result) { | |
| 233 | 233 | assert.strictEqual(err.path, entry); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,9 +24,9 @@ common.expectsError( | |||
| 24 | 24 | type: TypeError | |
| 25 | 25 | }); | |
| 26 | 26 | ||
| 27 | - assert.throws(function() { | ||
| 27 | + common.expectsError(function() { | ||
| 28 | 28 | fs.watchFile(new Object(), common.mustNotCall()); | |
| 29 | - }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError })); | ||
| 29 | + }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError }); | ||
| 30 | 30 | ||
| 31 | 31 | const enoentFile = path.join(common.tmpDir, 'non-existent-file'); | |
| 32 | 32 | const expectedStatObject = new fs.Stats( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | const http = require('http'); | |
| 5 | 4 | const Countdown = require('../common/countdown'); | |
| 6 | 5 | ||
@@ -18,14 +17,14 @@ const server = http.createServer(common.mustCall((req, res) => { | |||
| 18 | 17 | ||
| 19 | 18 | server.listen(0, common.mustCall(() => { | |
| 20 | 19 | expectedFails.forEach((method) => { | |
| 21 | - assert.throws(() => { | ||
| 20 | + common.expectsError(() => { | ||
| 22 | 21 | http.request({ method, path: '/' }, common.mustNotCall()); | |
| 23 | - }, common.expectsError({ | ||
| 22 | + }, { | ||
| 24 | 23 | code: 'ERR_INVALID_ARG_TYPE', | |
| 25 | 24 | type: TypeError, | |
| 26 | 25 | message: 'The "method" argument must be of type string. ' + | |
| 27 | 26 | `Received type ${typeof method}` | |
| 28 | - })); | ||
| 27 | + }); | ||
| 29 | 28 | }); | |
| 30 | 29 | ||
| 31 | 30 | expectedSuccesses.forEach((method) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,14 +47,14 @@ server.listen(0, baseOptions.host, common.mustCall(function() { | |||
| 47 | 47 | baseOptions.port = this.address().port; | |
| 48 | 48 | ||
| 49 | 49 | failingAgentOptions.forEach((agent) => { | |
| 50 | - assert.throws( | ||
| 50 | + common.expectsError( | ||
| 51 | 51 | () => createRequest(agent), | |
| 52 | - common.expectsError({ | ||
| 52 | + { | ||
| 53 | 53 | code: 'ERR_INVALID_ARG_TYPE', | |
| 54 | 54 | type: TypeError, | |
| 55 | 55 | message: 'The "Agent option" argument must be one of type ' + | |
| 56 | 56 | 'Agent-like Object, undefined, or false' | |
| 57 | - }) | ||
| 57 | + } | ||
| 58 | 58 | ); | |
| 59 | 59 | }); | |
| 60 | 60 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,17 +21,16 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | const common = require('../common'); | |
| 24 | - const assert = require('assert'); | ||
| 25 | 24 | const http = require('http'); | |
| 26 | 25 | ||
| 27 | 26 | for (let i = 0; i <= 32; i += 1) { | |
| 28 | 27 | const path = `bad${String.fromCharCode(i)}path`; | |
| 29 | - assert.throws( | ||
| 28 | + common.expectsError( | ||
| 30 | 29 | () => http.get({ path }, common.mustNotCall()), | |
| 31 | - common.expectsError({ | ||
| 30 | + { | ||
| 32 | 31 | code: 'ERR_UNESCAPED_CHARACTERS', | |
| 33 | 32 | type: TypeError, | |
| 34 | 33 | message: 'Request path contains unescaped characters' | |
| 35 | - }) | ||
| 34 | + } | ||
| 36 | 35 | ); | |
| 37 | 36 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,26 +9,26 @@ const http = require('http'); | |||
| 9 | 9 | const vals = [{}, [], NaN, Infinity, -Infinity, true, false, 1, 0, new Date()]; | |
| 10 | 10 | ||
| 11 | 11 | vals.forEach((v) => { | |
| 12 | - assert.throws( | ||
| 12 | + common.expectsError( | ||
| 13 | 13 | () => http.request({ hostname: v }), | |
| 14 | - common.expectsError({ | ||
| 14 | + { | ||
| 15 | 15 | code: 'ERR_INVALID_ARG_TYPE', | |
| 16 | 16 | type: TypeError, | |
| 17 | 17 | message: 'The "options.hostname" property must be one of ' + | |
| 18 | 18 | 'type string, undefined, or null. ' + | |
| 19 | 19 | `Received type ${typeof v}` | |
| 20 | - }) | ||
| 20 | + } | ||
| 21 | 21 | ); | |
| 22 | 22 | ||
| 23 | - assert.throws( | ||
| 23 | + common.expectsError( | ||
| 24 | 24 | () => http.request({ host: v }), | |
| 25 | - common.expectsError({ | ||
| 25 | + { | ||
| 26 | 26 | code: 'ERR_INVALID_ARG_TYPE', | |
| 27 | 27 | type: TypeError, | |
| 28 | 28 | message: 'The "options.host" property must be one of ' + | |
| 29 | 29 | 'type string, undefined, or null. ' + | |
| 30 | 30 | `Received type ${typeof v}` | |
| 31 | - }) | ||
| 31 | + } | ||
| 32 | 32 | ); | |
| 33 | 33 | }); | |
| 34 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | const http = require('http'); | |
| 5 | 4 | ||
| 6 | - assert.throws( | ||
| 5 | + common.expectsError( | ||
| 7 | 6 | () => http.request({ method: '\0' }), | |
| 8 | - common.expectsError({ | ||
| 7 | + { | ||
| 9 | 8 | code: 'ERR_INVALID_HTTP_TOKEN', | |
| 10 | 9 | type: TypeError, | |
| 11 | 10 | message: 'Method must be a valid HTTP token ["\u0000"]' | |
| 12 | - }) | ||
| 11 | + } | ||
| 13 | 12 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,12 +56,12 @@ const server = http.Server(common.mustCall(function(req, res) { | |||
| 56 | 56 | test(res, '404 this is not valid either', '404 this is not valid either'); | |
| 57 | 57 | break; | |
| 58 | 58 | case 12: | |
| 59 | - assert.throws(() => { res.writeHead(); }, | ||
| 60 | - common.expectsError({ | ||
| 61 | - code: 'ERR_HTTP_INVALID_STATUS_CODE', | ||
| 62 | - type: RangeError, | ||
| 63 | - message: 'Invalid status code: undefined' | ||
| 64 | - })); | ||
| 59 | + common.expectsError(() => { res.writeHead(); }, | ||
| 60 | + { | ||
| 61 | + code: 'ERR_HTTP_INVALID_STATUS_CODE', | ||
| 62 | + type: RangeError, | ||
| 63 | + message: 'Invalid status code: undefined' | ||
| 64 | + }); | ||
| 65 | 65 | this.close(); | |
| 66 | 66 | break; | |
| 67 | 67 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,8 @@ const server = http.createServer(common.mustCall(function(req, res) { | |||
| 14 | 14 | message: 'Trailers are invalid with this transfer encoding', | |
| 15 | 15 | type: Error | |
| 16 | 16 | }; | |
| 17 | - assert.throws(() => res.writeHead(200, { 'Content-Length': '2' }), | ||
| 18 | - common.expectsError(trailerInvalidErr)); | ||
| 17 | + common.expectsError(() => res.writeHead(200, { 'Content-Length': '2' }), | ||
| 18 | + trailerInvalidErr); | ||
| 19 | 19 | res.removeHeader('Trailer'); | |
| 20 | 20 | res.end('ok'); | |
| 21 | 21 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments