From e7b7d7279ce61c1334b76937f264a3164e560568 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Mon, 13 Feb 2017 21:51:19 +0100 Subject: [PATCH] test: cases to querystring related to empty string + Add cases to `qs.stringify` that return empty string + Add cases to `qs.parse` when `sep` or `eq` is empty PR-URL: https://github.com/nodejs/node/pull/11329 Reviewed-By: Yuta Hiroto Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- test/parallel/test-querystring.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index 9ee33f67573169..677717f1d6b916 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -231,8 +231,20 @@ assert.doesNotThrow(function() { assert.equal(f, 'a:b;q:x%3Ay%3By%3Az'); } +// empty string +assert.strictEqual(qs.stringify(), ''); +assert.strictEqual(qs.stringify(0), ''); +assert.strictEqual(qs.stringify([]), ''); +assert.strictEqual(qs.stringify(null), ''); +assert.strictEqual(qs.stringify(true), ''); + check(qs.parse(), {}); +// empty sep +check(qs.parse('a', []), { a: '' }); + +// empty eq +check(qs.parse('a', null, []), { '': 'a' }); // Test limiting assert.equal(