Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add cases for unescape & unescapeBuffer #11326

Closed
wants to merge 1 commit into from

Conversation

watilde
Copy link
Member

@watilde watilde commented Feb 12, 2017

Increase coverage of querystring:

This test case will cover these lines:

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test, querystring

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Feb 12, 2017
@mscdex mscdex added the querystring Issues and PRs related to the built-in querystring module. label Feb 12, 2017
@@ -304,6 +310,9 @@ assert.strictEqual(
qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }),
'a=a&b=b&c=c');

// Test QueryString.unescapeBuffer
assert.strictEqual(qs.unescape('%C4%97%'), 'ė%');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer having more direct tests against qs.unescapeBuffer() in addition to the indirect ones for qs.unescape(). Here are some nice test cases for unescapeBuffer().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing them! I've picked them and updated the test.

@hiroppy
Copy link
Member

hiroppy commented Feb 12, 2017

@jasnell
Copy link
Member

jasnell commented Feb 16, 2017

@TimothyGu ... PTAL

@TimothyGu
Copy link
Member

@watilde, sorry for not being clear. What I meant is calling qs.unescapeBuffer() directly, i.e. not though qs.unescape().

@watilde
Copy link
Member Author

watilde commented Feb 17, 2017

@TimothyGu To test this line, I needed calling qs.unescape() instead of qs.unescapeBuffer() to make an error by passing an option { decodeURIComponent: errDecode }.

@TimothyGu
Copy link
Member

@watilde, how about both?

These two functions in the querystring are used as a fallback.
To test them, two test cases were added which make errors that
will be caught.
@watilde
Copy link
Member Author

watilde commented Feb 17, 2017

@TimothyGu Ahh that's nice! I will add it to call the both methods.

@watilde
Copy link
Member Author

watilde commented Feb 17, 2017

Updates:

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhdawson
Copy link
Member

jasnell pushed a commit that referenced this pull request Feb 19, 2017
These two functions in the querystring are used as a fallback.
To test them, two test cases were added which make errors that
will be caught.

PR-URL: #11326
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@hiroppy
Copy link
Member

hiroppy commented Feb 25, 2017

landed in 02acea9

@hiroppy hiroppy closed this Feb 25, 2017
@watilde watilde deleted the test-qs branch February 25, 2017 16:08
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 25, 2017
These two functions in the querystring are used as a fallback.
To test them, two test cases were added which make errors that
will be caught.

PR-URL: nodejs#11326
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@italoacasas italoacasas mentioned this pull request Feb 25, 2017
jasnell pushed a commit that referenced this pull request Mar 7, 2017
These two functions in the querystring are used as a fallback.
To test them, two test cases were added which make errors that
will be caught.

PR-URL: #11326
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@jasnell
Copy link
Member

jasnell commented Mar 7, 2017

This will need a backport PR if it needs to land on v4.x-staging

MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
These two functions in the querystring are used as a fallback.
To test them, two test cases were added which make errors that
will be caught.

PR-URL: #11326
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
querystring Issues and PRs related to the built-in querystring module. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants