aboutsummaryrefslogtreecommitdiff
path: root/test/js/deno/fetch
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/deno/fetch')
-rw-r--r--test/js/deno/fetch/blob.test.ts25
-rw-r--r--test/js/deno/fetch/body.test.ts14
-rw-r--r--test/js/deno/fetch/headers.test.ts58
-rw-r--r--test/js/deno/fetch/request.test.ts18
-rw-r--r--test/js/deno/fetch/response.test.ts22
5 files changed, 73 insertions, 64 deletions
diff --git a/test/js/deno/fetch/blob.test.ts b/test/js/deno/fetch/blob.test.ts
index 8c9c7318c..5a6c2fb80 100644
--- a/test/js/deno/fetch/blob.test.ts
+++ b/test/js/deno/fetch/blob.test.ts
@@ -1,8 +1,9 @@
+// GENERATED - DO NOT EDIT
// Copyright 2018+ the Deno authors. All rights reserved. MIT license.
// https://raw.githubusercontent.com/denoland/deno/main/cli/tests/unit/blob_test.ts
-import { assert, assertEquals, assertStringIncludes } from "deno:harness";
-import { concat } from "deno:harness";
-Deno.test(function blobString() {
+import { createDenoTest } from "deno:harness";
+const { test, assert, assertEquals, assertStringIncludes, concat } = createDenoTest(import.meta.path);
+test(function blobString() {
const b1 = new Blob([
"Hello World"
]);
@@ -13,7 +14,7 @@ Deno.test(function blobString() {
]);
assertEquals(b2.size, b1.size + str.length);
});
-Deno.test(function blobBuffer() {
+test(function blobBuffer() {
const buffer = new ArrayBuffer(12);
const u8 = new Uint8Array(buffer);
const f1 = new Float32Array(buffer);
@@ -28,7 +29,7 @@ Deno.test(function blobBuffer() {
]);
assertEquals(b2.size, 3 * u8.length);
});
-Deno.test(function blobSlice() {
+test(function blobSlice() {
const blob = new Blob([
"Deno",
"Foo"
@@ -44,7 +45,7 @@ Deno.test(function blobSlice() {
const b4 = blob.slice(0, 10);
assertEquals(b4.size, blob.size);
});
-Deno.test(function blobInvalidType() {
+test(function blobInvalidType() {
const blob = new Blob([
"foo"
], {
@@ -52,7 +53,7 @@ Deno.test(function blobInvalidType() {
});
assertEquals(blob.type, "");
});
-Deno.test(function blobShouldNotThrowError() {
+test(function blobShouldNotThrowError() {
let hasThrown = false;
try {
const options1: any = {
@@ -71,13 +72,13 @@ Deno.test(function blobShouldNotThrowError() {
}
assertEquals(hasThrown, false);
});
-Deno.test(async function blobText() {
+test(async function blobText() {
const blob = new Blob([
"Hello World"
]);
assertEquals(await blob.text(), "Hello World");
});
-Deno.test(async function blobStream() {
+test(async function blobStream() {
const blob = new Blob([
"Hello World"
]);
@@ -96,7 +97,7 @@ Deno.test(async function blobStream() {
const decoder = new TextDecoder();
assertEquals(decoder.decode(bytes), "Hello World");
});
-Deno.test(async function blobArrayBuffer() {
+test(async function blobArrayBuffer() {
const uint = new Uint8Array([
102,
111,
@@ -107,11 +108,11 @@ Deno.test(async function blobArrayBuffer() {
]);
assertEquals(await blob.arrayBuffer(), uint.buffer);
});
-Deno.test(function blobConstructorNameIsBlob() {
+test(function blobConstructorNameIsBlob() {
const blob = new Blob();
assertEquals(blob.constructor.name, "Blob");
});
-Deno.test.ignore(function blobCustomInspectFunction() {
+test.ignore(function blobCustomInspectFunction() {
const blob = new Blob();
assertEquals(Deno.inspect(blob), `Blob { size: 0, type: "" }`);
assertStringIncludes(Deno.inspect(Blob.prototype), "Blob");
diff --git a/test/js/deno/fetch/body.test.ts b/test/js/deno/fetch/body.test.ts
index 87966bc48..6aa6cbb73 100644
--- a/test/js/deno/fetch/body.test.ts
+++ b/test/js/deno/fetch/body.test.ts
@@ -1,6 +1,8 @@
+// GENERATED - DO NOT EDIT
// Copyright 2018+ the Deno authors. All rights reserved. MIT license.
// https://raw.githubusercontent.com/denoland/deno/main/cli/tests/unit/body_test.ts
-import { assert, assertEquals } from "deno:harness";
+import { createDenoTest } from "deno:harness";
+const { test, assert, assertEquals } = createDenoTest(import.meta.path);
function buildBody(body: any, headers?: Headers): Body {
const stub = new Request("http://foo/", {
body: body,
@@ -20,7 +22,7 @@ const intArrays = [
Float32Array,
Float64Array
];
-Deno.test(async function arrayBufferFromByteArrays() {
+test(async function arrayBufferFromByteArrays() {
const buffer = new TextEncoder().encode("ahoyhoy8").buffer;
for (const type of intArrays){
const body = buildBody(new type(buffer));
@@ -28,7 +30,7 @@ Deno.test(async function arrayBufferFromByteArrays() {
assertEquals(text, "ahoyhoy8");
}
});
-Deno.test({
+test({
permissions: {
net: true
}
@@ -42,7 +44,7 @@ Deno.test({
assertEquals(formData.get("field_1")!.toString(), "value_1 \r\n");
assert(formData.has("field_2"));
});
-Deno.test({
+test({
permissions: {
net: true
}
@@ -57,7 +59,7 @@ Deno.test({
assert(formData.has("field_2"));
assertEquals(formData.get("field_2")!.toString(), "<Deno>");
});
-Deno.test({
+test({
permissions: {}
}, async function bodyURLSearchParams() {
const body = buildBody(new URLSearchParams({
@@ -66,7 +68,7 @@ Deno.test({
const text = await body.text();
assertEquals(text, "hello=world");
});
-Deno.test(async function bodyArrayBufferMultipleParts() {
+test(async function bodyArrayBufferMultipleParts() {
const parts: Uint8Array[] = [];
let size = 0;
for(let i = 0; i <= 150000; i++){
diff --git a/test/js/deno/fetch/headers.test.ts b/test/js/deno/fetch/headers.test.ts
index 1bac1b93c..ee2466e32 100644
--- a/test/js/deno/fetch/headers.test.ts
+++ b/test/js/deno/fetch/headers.test.ts
@@ -1,11 +1,13 @@
+// GENERATED - DO NOT EDIT
// Copyright 2018+ the Deno authors. All rights reserved. MIT license.
// https://raw.githubusercontent.com/denoland/deno/main/cli/tests/unit/headers_test.ts
-import { assert, assertEquals, assertThrows } from "deno:harness";
+import { createDenoTest } from "deno:harness";
+const { test, assert, assertEquals, assertThrows } = createDenoTest(import.meta.path);
const { inspectArgs } = Deno[Deno.internal];
-Deno.test(function headersHasCorrectNameProp() {
+test(function headersHasCorrectNameProp() {
assertEquals(Headers.name, "Headers");
});
-Deno.test(function newHeaderTest() {
+test(function newHeaderTest() {
new Headers();
new Headers(undefined);
new Headers({});
@@ -29,48 +31,48 @@ for (const [name, value] of Object.entries(headerDict)){
value
]);
}
-Deno.test(function newHeaderWithSequence() {
+test(function newHeaderWithSequence() {
const headers = new Headers(headerSeq);
for (const [name, value] of Object.entries(headerDict)){
assertEquals(headers.get(name), String(value));
}
assertEquals(headers.get("length"), null);
});
-Deno.test(function newHeaderWithRecord() {
+test(function newHeaderWithRecord() {
const headers = new Headers(headerDict);
for (const [name, value] of Object.entries(headerDict)){
assertEquals(headers.get(name), String(value));
}
});
-Deno.test(function newHeaderWithHeadersInstance() {
+test(function newHeaderWithHeadersInstance() {
const headers = new Headers(headerDict);
const headers2 = new Headers(headers);
for (const [name, value] of Object.entries(headerDict)){
assertEquals(headers2.get(name), String(value));
}
});
-Deno.test(function headerAppendSuccess() {
+test(function headerAppendSuccess() {
const headers = new Headers();
for (const [name, value] of Object.entries(headerDict)){
headers.append(name, value);
assertEquals(headers.get(name), String(value));
}
});
-Deno.test(function headerSetSuccess() {
+test(function headerSetSuccess() {
const headers = new Headers();
for (const [name, value] of Object.entries(headerDict)){
headers.set(name, value);
assertEquals(headers.get(name), String(value));
}
});
-Deno.test(function headerHasSuccess() {
+test(function headerHasSuccess() {
const headers = new Headers(headerDict);
for (const name of Object.keys(headerDict)){
assert(headers.has(name), "headers has name " + name);
assert(!headers.has("nameNotInHeaders"), "headers do not have header: nameNotInHeaders");
}
});
-Deno.test(function headerDeleteSuccess() {
+test(function headerDeleteSuccess() {
const headers = new Headers(headerDict);
for (const name of Object.keys(headerDict)){
assert(headers.has(name), "headers have a header: " + name);
@@ -78,14 +80,14 @@ Deno.test(function headerDeleteSuccess() {
assert(!headers.has(name), "headers do not have anymore a header: " + name);
}
});
-Deno.test(function headerGetSuccess() {
+test(function headerGetSuccess() {
const headers = new Headers(headerDict);
for (const [name, value] of Object.entries(headerDict)){
assertEquals(headers.get(name), String(value));
assertEquals(headers.get("nameNotInHeaders"), null);
}
});
-Deno.test(function headerEntriesSuccess() {
+test(function headerEntriesSuccess() {
const headers = new Headers(headerDict);
const iterators = headers.entries();
for (const it of iterators){
@@ -95,14 +97,14 @@ Deno.test(function headerEntriesSuccess() {
assertEquals(value, headers.get(key));
}
});
-Deno.test(function headerKeysSuccess() {
+test(function headerKeysSuccess() {
const headers = new Headers(headerDict);
const iterators = headers.keys();
for (const it of iterators){
assert(headers.has(it));
}
});
-Deno.test(function headerValuesSuccess() {
+test(function headerValuesSuccess() {
const headers = new Headers(headerDict);
const iterators = headers.values();
const entries = headers.entries();
@@ -122,7 +124,7 @@ const headerEntriesDict: Record<string, string> = {
"Content-Typ": "value5",
"Content-Types": "value6"
};
-Deno.test(function headerForEachSuccess() {
+test(function headerForEachSuccess() {
const headers = new Headers(headerEntriesDict);
const keys = Object.keys(headerEntriesDict);
keys.forEach((key)=>{
@@ -138,7 +140,7 @@ Deno.test(function headerForEachSuccess() {
});
assertEquals(callNum, keys.length);
});
-Deno.test(function headerSymbolIteratorSuccess() {
+test(function headerSymbolIteratorSuccess() {
assert(Symbol.iterator in Headers.prototype);
const headers = new Headers(headerEntriesDict);
for (const header of headers){
@@ -148,14 +150,14 @@ Deno.test(function headerSymbolIteratorSuccess() {
assertEquals(value, headers.get(key));
}
});
-Deno.test(function headerTypesAvailable() {
+test(function headerTypesAvailable() {
function newHeaders(): Headers {
return new Headers();
}
const headers = newHeaders();
assert(headers instanceof Headers);
});
-Deno.test(function headerIllegalReject() {
+test(function headerIllegalReject() {
let errorCount = 0;
try {
new Headers({
@@ -214,7 +216,7 @@ Deno.test(function headerIllegalReject() {
"He-y": "o k"
});
});
-Deno.test(function headerParamsShouldThrowTypeError() {
+test(function headerParamsShouldThrowTypeError() {
let hasThrown = 0;
try {
new Headers(([
@@ -232,7 +234,7 @@ Deno.test(function headerParamsShouldThrowTypeError() {
}
assertEquals(hasThrown, 2);
});
-Deno.test(function headerParamsArgumentsCheck() {
+test(function headerParamsArgumentsCheck() {
const methodRequireOneParam = [
"delete",
"get",
@@ -286,7 +288,7 @@ Deno.test(function headerParamsArgumentsCheck() {
assertEquals(hasThrown, 2);
});
});
-Deno.test(function headersInitMultiple() {
+test(function headersInitMultiple() {
const headers = new Headers([
[
"Set-Cookie",
@@ -323,7 +325,7 @@ Deno.test(function headersInitMultiple() {
]
]);
});
-Deno.test(function headerInitWithPrototypePollution() {
+test(function headerInitWithPrototypePollution() {
const originalExec = RegExp.prototype.exec;
try {
RegExp.prototype.exec = ()=>{
@@ -343,7 +345,7 @@ Deno.test(function headerInitWithPrototypePollution() {
RegExp.prototype.exec = originalExec;
}
});
-Deno.test(function headersAppendMultiple() {
+test(function headersAppendMultiple() {
const headers = new Headers([
[
"Set-Cookie",
@@ -374,7 +376,7 @@ Deno.test(function headersAppendMultiple() {
]
]);
});
-Deno.test(function headersAppendDuplicateSetCookieKey() {
+test(function headersAppendDuplicateSetCookieKey() {
const headers = new Headers([
[
"Set-Cookie",
@@ -401,7 +403,7 @@ Deno.test(function headersAppendDuplicateSetCookieKey() {
]
]);
});
-Deno.test(function headersGetSetCookie() {
+test(function headersGetSetCookie() {
const headers = new Headers([
[
"Set-Cookie",
@@ -414,14 +416,14 @@ Deno.test(function headersGetSetCookie() {
]);
assertEquals(headers.get("SET-COOKIE"), "foo=bar, bar=qat");
});
-Deno.test(function toStringShouldBeWebCompatibility() {
+test(function toStringShouldBeWebCompatibility() {
const headers = new Headers();
assertEquals(headers.toString(), "[object Headers]");
});
function stringify(...args: unknown[]): string {
return inspectArgs(args).replace(/\n$/, "");
}
-Deno.test.ignore(function customInspectReturnsCorrectHeadersFormat() {
+test.ignore(function customInspectReturnsCorrectHeadersFormat() {
const blankHeaders = new Headers();
assertEquals(stringify(blankHeaders), "Headers {}");
const singleHeader = new Headers([
@@ -443,7 +445,7 @@ Deno.test.ignore(function customInspectReturnsCorrectHeadersFormat() {
]);
assertEquals(stringify(multiParamHeader), `Headers { "content-length": "1337", "content-type": "application/json" }`);
});
-Deno.test(function invalidHeadersFlaky() {
+test(function invalidHeadersFlaky() {
assertThrows(()=>new Headers([
[
"x",
diff --git a/test/js/deno/fetch/request.test.ts b/test/js/deno/fetch/request.test.ts
index d1a444196..3f182c77c 100644
--- a/test/js/deno/fetch/request.test.ts
+++ b/test/js/deno/fetch/request.test.ts
@@ -1,7 +1,9 @@
+// GENERATED - DO NOT EDIT
// Copyright 2018+ the Deno authors. All rights reserved. MIT license.
// https://raw.githubusercontent.com/denoland/deno/main/cli/tests/unit/request_test.ts
-import { assertEquals, assertStringIncludes } from "deno:harness";
-Deno.test(async function fromInit() {
+import { createDenoTest } from "deno:harness";
+const { test, assertEquals, assertStringIncludes } = createDenoTest(import.meta.path);
+test(async function fromInit() {
const req = new Request("http://foo/", {
body: "ahoyhoy",
method: "POST",
@@ -13,7 +15,7 @@ Deno.test(async function fromInit() {
assertEquals(req.url, "http://foo/");
assertEquals(req.headers.get("test-header"), "value");
});
-Deno.test(function requestNonString() {
+test(function requestNonString() {
const nonString = {
toString () {
return "http://foo/";
@@ -21,15 +23,15 @@ Deno.test(function requestNonString() {
};
assertEquals(new Request(nonString).url, "http://foo/");
});
-Deno.test(function methodNonString() {
+test(function methodNonString() {
assertEquals(new Request("http://foo/", {
method: undefined
}).method, "GET");
});
-Deno.test.ignore(function requestRelativeUrl() {
+test.ignore(function requestRelativeUrl() {
assertEquals(new Request("relative-url").url, "http://js-unit-tests/foo/relative-url");
});
-Deno.test(async function cloneRequestBodyStream() {
+test(async function cloneRequestBodyStream() {
const stream = new Request("http://foo/", {
body: "a test body",
method: "POST"
@@ -43,7 +45,7 @@ Deno.test(async function cloneRequestBodyStream() {
const b2 = await r2.text();
assertEquals(b1, b2);
});
-Deno.test.ignore(function customInspectFunction() {
+test.ignore(function customInspectFunction() {
const request = new Request("https://example.com");
assertEquals(Deno.inspect(request), `Request {
bodyUsed: false,
@@ -54,6 +56,6 @@ Deno.test.ignore(function customInspectFunction() {
}`);
assertStringIncludes(Deno.inspect(Request.prototype), "Request");
});
-Deno.test(function requestConstructorTakeURLObjectAsParameter() {
+test(function requestConstructorTakeURLObjectAsParameter() {
assertEquals(new Request(new URL("http://foo/")).url, "http://foo/");
});
diff --git a/test/js/deno/fetch/response.test.ts b/test/js/deno/fetch/response.test.ts
index 2e83ed0d8..a8066c75b 100644
--- a/test/js/deno/fetch/response.test.ts
+++ b/test/js/deno/fetch/response.test.ts
@@ -1,7 +1,9 @@
+// GENERATED - DO NOT EDIT
// Copyright 2018+ the Deno authors. All rights reserved. MIT license.
// https://raw.githubusercontent.com/denoland/deno/main/cli/tests/unit/response_test.ts
-import { assert, assertEquals, assertStringIncludes, assertThrows } from "deno:harness";
-Deno.test(async function responseText() {
+import { createDenoTest } from "deno:harness";
+const { test, assert, assertEquals, assertStringIncludes, assertThrows } = createDenoTest(import.meta.path);
+test(async function responseText() {
const response = new Response("hello world");
const textPromise = response.text();
assert(textPromise instanceof Promise);
@@ -9,7 +11,7 @@ Deno.test(async function responseText() {
assert(typeof text === "string");
assertEquals(text, "hello world");
});
-Deno.test(async function responseArrayBuffer() {
+test(async function responseArrayBuffer() {
const response = new Response(new Uint8Array([
1,
2,
@@ -25,7 +27,7 @@ Deno.test(async function responseArrayBuffer() {
3
]));
});
-Deno.test(async function responseJson() {
+test(async function responseJson() {
const response = new Response('{"hello": "world"}');
const jsonPromise = response.json();
assert(jsonPromise instanceof Promise);
@@ -35,7 +37,7 @@ Deno.test(async function responseJson() {
hello: "world"
});
});
-Deno.test(async function responseBlob() {
+test(async function responseBlob() {
const response = new Response(new Uint8Array([
1,
2,
@@ -52,7 +54,7 @@ Deno.test(async function responseBlob() {
3
]).buffer);
});
-Deno.test(async function responseFormData() {
+test(async function responseFormData() {
const input = new FormData();
input.append("hello", "world");
const response = new Response(input);
@@ -68,7 +70,7 @@ Deno.test(async function responseFormData() {
...input
]);
});
-Deno.test(function responseInvalidInit() {
+test(function responseInvalidInit() {
assertThrows(()=>new Response("", 0));
assertThrows(()=>new Response("", {
status: 0
@@ -77,11 +79,11 @@ Deno.test(function responseInvalidInit() {
status: null
}));
});
-Deno.test(function responseNullInit() {
+test(function responseNullInit() {
const response = new Response("", null);
assertEquals(response.status, 200);
});
-Deno.test.ignore(function customInspectFunction() {
+test.ignore(function customInspectFunction() {
const response = new Response();
assertEquals(Deno.inspect(response), `Response {
body: null,
@@ -95,7 +97,7 @@ Deno.test.ignore(function customInspectFunction() {
}`);
assertStringIncludes(Deno.inspect(Response.prototype), "Response");
});
-Deno.test(async function responseBodyUsed() {
+test(async function responseBodyUsed() {
const response = new Response("body");
assert(!response.bodyUsed);
await response.text();