-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add tests for body property handling in Request constructor #4612
Add tests for body property handling in Request constructor #4612
Conversation
Notifying @jdm and @youennf. (Learn how reviewing works.) |
These new tests look good to me. I'm not going to merge them until someone else says that they're testing the cases we care about for the fetch PRs mentioned in the original comment. |
cc: @annevk |
assert_true(bodyRequest.bodyUsed , "bodyUsed is true when request is disturbed"); | ||
assert_equals(bodyRequest.body, originalBody, "body should not change"); | ||
assert_not_equals(originalBody, undefined, "body should not be undefined"); | ||
assert_not_equals(originalBody, null, "body should not be null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test here about what it should be? Either instanceof/typeof or some such?
And perhaps we should also have a test where the initial request does not have a body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I found that I forgot to expose body property on Request. I'll make another fetch spec PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I added some assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just add that to the existing PR? Then we can use these tests for both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, what you did is fine.
assert_false(bodyRequest.bodyUsed , "bodyUsed is false when request is not disturbed"); | ||
var requestFromRequest = new Request(bodyRequest); | ||
assert_true(bodyRequest.bodyUsed , "bodyUsed is true when request is disturbed"); | ||
assert_equals(bodyRequest.body, originalBody, "body should not change"); | ||
assert_not_equals(originalBody, undefined, "body should not be undefined"); | ||
assert_not_equals(originalBody, null, "body should not be null"); | ||
}, "Input request used for creating new request became disturbed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is basically duplicated no as a promise_test, no? Maybe it's better to just remove it? Or am I missing something subtle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, the difference is that the promise_test passes a body. Disregard the above comment please.
This change is for whatwg/fetch#425 and whatwg/fetch#458.