|
20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 | 21 |
|
22 | 22 | 'use strict'; |
23 | | -require('../common'); |
| 23 | +const common = require('../common'); |
24 | 24 | const assert = require('assert'); |
25 | 25 | const path = require('path'); |
26 | 26 |
|
@@ -88,29 +88,21 @@ const unixSpecialCaseFormatTests = [ |
88 | 88 | [{}, ''] |
89 | 89 | ]; |
90 | 90 |
|
| 91 | +const expectedMessage = common.expectsError({ |
| 92 | + code: 'ERR_INVALID_ARG_TYPE', |
| 93 | + type: TypeError |
| 94 | +}); |
| 95 | + |
91 | 96 | const errors = [ |
92 | | - {method: 'parse', input: [null], |
93 | | - message: /^TypeError: Path must be a string\. Received null$/}, |
94 | | - {method: 'parse', input: [{}], |
95 | | - message: /^TypeError: Path must be a string\. Received {}$/}, |
96 | | - {method: 'parse', input: [true], |
97 | | - message: /^TypeError: Path must be a string\. Received true$/}, |
98 | | - {method: 'parse', input: [1], |
99 | | - message: /^TypeError: Path must be a string\. Received 1$/}, |
100 | | - {method: 'parse', input: [], |
101 | | - message: /^TypeError: Path must be a string\. Received undefined$/}, |
102 | | - {method: 'format', input: [null], |
103 | | - message: |
104 | | - /^TypeError: Parameter "pathObject" must be an object, not object$/}, |
105 | | - {method: 'format', input: [''], |
106 | | - message: |
107 | | - /^TypeError: Parameter "pathObject" must be an object, not string$/}, |
108 | | - {method: 'format', input: [true], |
109 | | - message: |
110 | | - /^TypeError: Parameter "pathObject" must be an object, not boolean$/}, |
111 | | - {method: 'format', input: [1], |
112 | | - message: |
113 | | - /^TypeError: Parameter "pathObject" must be an object, not number$/}, |
| 97 | + {method: 'parse', input: [null], message: expectedMessage}, |
| 98 | + {method: 'parse', input: [{}], message: expectedMessage}, |
| 99 | + {method: 'parse', input: [true], message: expectedMessage}, |
| 100 | + {method: 'parse', input: [1], message: expectedMessage}, |
| 101 | + {method: 'parse', input: [], message: expectedMessage}, |
| 102 | + {method: 'format', input: [null], message: expectedMessage}, |
| 103 | + {method: 'format', input: [''], message: expectedMessage}, |
| 104 | + {method: 'format', input: [true], message: expectedMessage}, |
| 105 | + {method: 'format', input: [1], message: expectedMessage}, |
114 | 106 | ]; |
115 | 107 |
|
116 | 108 | checkParseFormat(path.win32, winPaths); |
|
0 commit comments