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

feature: add query as object constructor and tests #367

Merged
merged 5 commits into from
Feb 10, 2018
Merged

feature: add query as object constructor and tests #367

merged 5 commits into from
Feb 10, 2018

Conversation

wachunei
Copy link
Contributor

Attempt to resolve #366

Copy link
Member

@rodneyrehm rodneyrehm left a comment

Choose a reason for hiding this comment

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

looks great! do you want to extend the exception for the fragment as well?

src/URI.js Outdated
if (hasOwn.call(this._parts, key)) {
this._parts[key] = src[key];
}
}
this.query(src['query']);
Copy link
Member

Choose a reason for hiding this comment

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

this should probably only be executed if src.query is actually defined

Copy link
Contributor Author

@wachunei wachunei Feb 10, 2018

Choose a reason for hiding this comment

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

definitely! will update.

edit: should it be a test that fail in this case? all tests were passing anyway.

src/URI.js Outdated
for (key in src) {
if (key === 'query') {
hasQueryPart = true;
Copy link
Contributor Author

@wachunei wachunei Feb 10, 2018

Choose a reason for hiding this comment

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

wait a second, this can be true even if src['query'] is undefined, isnt it?
maybe I should have changed it to

if (key === 'query' && src[key] !== undefined) {

Copy link
Member

Choose a reason for hiding this comment

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

you can keep the if (key === 'query') { continue; } part and add if (src.query) { this.query(src.query, false); }. you only need to execute .query() if there actually is a value (other than null, undefined, empty-string)

@wachunei
Copy link
Contributor Author

About fragments: I think we should open its own issue and solve it in its own PR.

Copy link
Member

@rodneyrehm rodneyrehm left a comment

Choose a reason for hiding this comment

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

the tests could use equal() and deepEqual() to provide better messages in case of failure

test/test.js Outdated
});
ok(u instanceof URI, 'instanceof URI');
ok(typeof u.query() === 'string', 'query is string');
ok(u.query() === 'foo=bar&bar=foo', 'query has right value');
Copy link
Member

Choose a reason for hiding this comment

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

equal(u.query(), 'foo=bar&bar=foo', 'query() value');

test/test.js Outdated
ok(typeof u.query() === 'string', 'query is string');
ok(u.query() === 'foo=bar&bar=foo', 'query has right value');
ok(u.search() === '?foo=bar&bar=foo', 'search has right value');
ok(typeof u.query(true) === 'object', 'query map is object');
Copy link
Member

Choose a reason for hiding this comment

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

deepEqual(u.query(true), { foo: 'bar', bar: 'foo' }, 'query(true) value');

@rodneyrehm
Copy link
Member

About fragments: I think we should open its own issue and solve it in its own PR.

fine by me :)

@rodneyrehm rodneyrehm merged commit ec3d57b into medialize:master Feb 10, 2018
@rodneyrehm
Copy link
Member

thank you!

@wachunei
Copy link
Contributor Author

You're welcome, looking forward to this being released! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants