deno: Possible broken test case "responseFormData"
Hi,
I’m currently working on a #8063 to make assertions handle symbols correctly, but it seems to reveal a broken test case.
The test in question is responseFormData which is below :
unitTest(async function responseFormData() {
const input = new FormData();
input.append("hello", "world");
const response = new Response(input, {
headers: { "content-type": "application/x-www-form-urlencoded" },
});
const formDataPromise = response.formData();
assert(formDataPromise instanceof Promise);
const formData = await formDataPromise;
assert(formData instanceof FormData);
assertEquals(formData, input);
});
It fails with the following result when using symbol checks :
AssertionError: Values are not equal:
[Diff] Actual / Expected
FormData {
[Symbol(data)]: [
[
- "[object FormData]",
- "",
+ "hello",
+ "world",
],
],
}
With Deno.inspect , input returns FormData { [Symbol(data)]: [ [ "hello", "world" ] ] while formData returns FormData { [Symbol(data)]: [ [ "[object FormData]", "" ] ] } (like if the formData was casted to string mistakenly).
My guess is that since data are indexed with a symbol instead of a regular key, the assertEquals was actually ignoring it (because it uses for (const key in object) which doesn’t include symbols).
It could possibly mean that response.formData() or this test case is actually broken.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (12 by maintainers)
hey @lucacasonato , I would like to give this issue a try, can I work on it??
Interesting. Looks like a bug in our
Body::formDatamethod. I will investigate.