Skip to content

Commit

Permalink
test: make test-querystring-escape engine agnostic
Browse files Browse the repository at this point in the history
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: #16272
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
Trott authored and evanlucas committed Nov 13, 2017
1 parent e2f5648 commit 591a692
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/parallel/test-querystring-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ assert.strictEqual(
'test'
);

// toString is not callable, must throw an error
assert.throws(() => qs.escape({ toString: 5 }),
/^TypeError: Cannot convert object to primitive value$/);
// `toString` is not callable, must throw an error.
// Error message will vary between different JavaScript engines, so only check
// 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.throws(() => qs.escape(Symbol('test')),
/^TypeError: Cannot convert a Symbol value to a string$/);
// Error message will vary between different JavaScript engines, so only check
// that it is a `TypeError`.
assert.throws(() => qs.escape(Symbol('test')), TypeError);

0 comments on commit 591a692

Please sign in to comment.