|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +require('../common'); |
| 4 | + |
| 5 | +const { URLPattern } = require('url'); |
| 6 | +const { throws } = require('assert'); |
| 7 | + |
| 8 | +// Verifies that calling URLPattern with no new keyword throws. |
| 9 | +throws(() => URLPattern(), { |
| 10 | + code: 'ERR_CONSTRUCT_CALL_REQUIRED', |
| 11 | +}); |
| 12 | + |
| 13 | +// Verifies that type checks are performed on the arguments. |
| 14 | +throws(() => new URLPattern(1), { |
| 15 | + code: 'ERR_INVALID_ARG_TYPE', |
| 16 | +}); |
| 17 | + |
| 18 | +throws(() => new URLPattern({}, 1), { |
| 19 | + code: 'ERR_INVALID_ARG_TYPE', |
| 20 | +}); |
| 21 | + |
| 22 | +throws(() => new URLPattern({}, '', 1), { |
| 23 | + code: 'ERR_INVALID_ARG_TYPE', |
| 24 | +}); |
| 25 | + |
| 26 | +throws(() => new URLPattern({}, { ignoreCase: '' }), { |
| 27 | + code: 'ERR_INVALID_ARG_TYPE', |
| 28 | +}); |
| 29 | + |
| 30 | +const pattern = new URLPattern(); |
| 31 | + |
| 32 | +throws(() => pattern.exec(1), { |
| 33 | + code: 'ERR_INVALID_ARG_TYPE', |
| 34 | +}); |
| 35 | + |
| 36 | +throws(() => pattern.exec('', 1), { |
| 37 | + code: 'ERR_INVALID_ARG_TYPE', |
| 38 | +}); |
| 39 | + |
| 40 | +throws(() => pattern.test(1), { |
| 41 | + code: 'ERR_INVALID_ARG_TYPE', |
| 42 | +}); |
| 43 | + |
| 44 | +throws(() => pattern.test('', 1), { |
| 45 | + code: 'ERR_INVALID_ARG_TYPE', |
| 46 | +}); |
0 commit comments