test: make test-querystring-escape engine agnostic
Do not check the error message if it is generated by the JavaScript engine (V8, ChakraCore, etc.). Do confirm that it is a `TypeError`. PR-URL: https://github.com/nodejs/node/pull/16272 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
parent
809da849f2
commit
0efb6db390
@ -28,12 +28,14 @@ assert.strictEqual(
|
|||||||
'test'
|
'test'
|
||||||
);
|
);
|
||||||
|
|
||||||
// toString is not callable, must throw an error
|
// `toString` is not callable, must throw an error.
|
||||||
assert.throws(() => qs.escape({ toString: 5 }),
|
// Error message will vary between different JavaScript engines, so only check
|
||||||
/^TypeError: Cannot convert object to primitive value$/);
|
// that it is a `TypeError`.
|
||||||
|
assert.throws(() => qs.escape({ toString: 5 }), TypeError);
|
||||||
|
|
||||||
// should use valueOf instead of non-callable toString
|
// Should use valueOf instead of non-callable toString.
|
||||||
assert.strictEqual(qs.escape({ toString: 5, valueOf: () => 'test' }), 'test');
|
assert.strictEqual(qs.escape({ toString: 5, valueOf: () => 'test' }), 'test');
|
||||||
|
|
||||||
assert.throws(() => qs.escape(Symbol('test')),
|
// Error message will vary between different JavaScript engines, so only check
|
||||||
/^TypeError: Cannot convert a Symbol value to a string$/);
|
// that it is a `TypeError`.
|
||||||
|
assert.throws(() => qs.escape(Symbol('test')), TypeError);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user