diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-03-06 20:48:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 20:48:46 -0500 |
commit | c42a9d737081fb8ee768c7178dae0e1f19c0f343 (patch) | |
tree | 9ffb7e502da62793ea099c34bd7b29c8a7a19b19 /js/fetch_test.ts | |
parent | de1a10e5f7afe793a66b2349642ea135fc066104 (diff) |
Upgrade deno_std (#1892)
A major API change was that asserts are imported from testing/asserts.ts
now rather than testing/mod.ts and assertEqual as renamed to
assertEquals to conform to what is most common in JavaScript.
Diffstat (limited to 'js/fetch_test.ts')
-rw-r--r-- | js/fetch_test.ts | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/js/fetch_test.ts b/js/fetch_test.ts index a931a26a4..4197e9c71 100644 --- a/js/fetch_test.ts +++ b/js/fetch_test.ts @@ -1,10 +1,10 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assert, assertEqual } from "./test_util.ts"; +import { test, testPerm, assert, assertEquals } from "./test_util.ts"; testPerm({ net: true }, async function fetchJsonSuccess() { const response = await fetch("http://localhost:4545/package.json"); const json = await response.json(); - assertEqual(json.name, "deno"); + assertEquals(json.name, "deno"); }); test(async function fetchPerm() { @@ -14,14 +14,14 @@ test(async function fetchPerm() { } catch (err_) { err = err_; } - assertEqual(err.kind, Deno.ErrorKind.PermissionDenied); - assertEqual(err.name, "PermissionDenied"); + assertEquals(err.kind, Deno.ErrorKind.PermissionDenied); + assertEquals(err.name, "PermissionDenied"); }); testPerm({ net: true }, async function fetchHeaders() { const response = await fetch("http://localhost:4545/package.json"); const headers = response.headers; - assertEqual(headers.get("Content-Type"), "application/json"); + assertEquals(headers.get("Content-Type"), "application/json"); assert(headers.get("Server").startsWith("SimpleHTTP")); }); @@ -29,20 +29,20 @@ testPerm({ net: true }, async function fetchBlob() { const response = await fetch("http://localhost:4545/package.json"); const headers = response.headers; const blob = await response.blob(); - assertEqual(blob.type, headers.get("Content-Type")); - assertEqual(blob.size, Number(headers.get("Content-Length"))); + assertEquals(blob.type, headers.get("Content-Type")); + assertEquals(blob.size, Number(headers.get("Content-Length"))); }); testPerm({ net: true }, async function responseClone() { const response = await fetch("http://localhost:4545/package.json"); const response1 = response.clone(); assert(response !== response1); - assertEqual(response.status, response1.status); - assertEqual(response.statusText, response1.statusText); + assertEquals(response.status, response1.status); + assertEquals(response.statusText, response1.statusText); const ab = await response.arrayBuffer(); const ab1 = await response1.arrayBuffer(); for (let i = 0; i < ab.byteLength; i++) { - assertEqual(ab[i], ab1[i]); + assertEquals(ab[i], ab1[i]); } }); @@ -53,8 +53,8 @@ testPerm({ net: true }, async function fetchEmptyInvalid() { } catch (err_) { err = err_; } - assertEqual(err.kind, Deno.ErrorKind.InvalidUri); - assertEqual(err.name, "InvalidUri"); + assertEquals(err.kind, Deno.ErrorKind.InvalidUri); + assertEquals(err.name, "InvalidUri"); }); testPerm({ net: true }, async function fetchMultipartFormDataSuccess() { @@ -63,11 +63,11 @@ testPerm({ net: true }, async function fetchMultipartFormDataSuccess() { ); const formData = await response.formData(); assert(formData.has("field_1")); - assertEqual(formData.get("field_1").toString(), "value_1 \r\n"); + assertEquals(formData.get("field_1").toString(), "value_1 \r\n"); assert(formData.has("field_2")); /* TODO(ry) Re-enable this test once we bring back the global File type. const file = formData.get("field_2") as File; - assertEqual(file.name, "file.js"); + assertEquals(file.name, "file.js"); */ // Currently we cannot read from file... }); @@ -78,9 +78,9 @@ testPerm({ net: true }, async function fetchURLEncodedFormDataSuccess() { ); const formData = await response.formData(); assert(formData.has("field_1")); - assertEqual(formData.get("field_1").toString(), "Hi"); + assertEquals(formData.get("field_1").toString(), "Hi"); assert(formData.has("field_2")); - assertEqual(formData.get("field_2").toString(), "<Deno>"); + assertEquals(formData.get("field_2").toString(), "<Deno>"); }); testPerm({ net: true }, async function fetchInitStringBody() { @@ -90,7 +90,7 @@ testPerm({ net: true }, async function fetchInitStringBody() { body: data }); const text = await response.text(); - assertEqual(text, data); + assertEquals(text, data); assert(response.headers.get("content-type").startsWith("text/plain")); }); @@ -101,7 +101,7 @@ testPerm({ net: true }, async function fetchInitTypedArrayBody() { body: new TextEncoder().encode(data) }); const text = await response.text(); - assertEqual(text, data); + assertEquals(text, data); }); testPerm({ net: true }, async function fetchInitURLSearchParamsBody() { @@ -112,7 +112,7 @@ testPerm({ net: true }, async function fetchInitURLSearchParamsBody() { body: params }); const text = await response.text(); - assertEqual(text, data); + assertEquals(text, data); assert( response.headers .get("content-type") @@ -130,7 +130,7 @@ testPerm({ net: true }, async function fetchInitBlobBody() { body: blob }); const text = await response.text(); - assertEqual(text, data); + assertEquals(text, data); assert(response.headers.get("content-type").startsWith("text/javascript")); }); @@ -138,7 +138,7 @@ testPerm({ net: true }, async function fetchInitBlobBody() { // somewhere. Here is what one of these flaky failures looks like: // // test fetchPostBodyString_permW0N1E0R0 -// assertEqual failed. actual = expected = POST /blah HTTP/1.1 +// assertEquals failed. actual = expected = POST /blah HTTP/1.1 // hello: World // foo: Bar // host: 127.0.0.1:4502 @@ -150,7 +150,7 @@ testPerm({ net: true }, async function fetchInitBlobBody() { // host: 127.0.0.1:4502 // content-length: 11 // hello world -// at Object.assertEqual (file:///C:/deno/js/testing/util.ts:29:11) +// at Object.assertEquals (file:///C:/deno/js/testing/util.ts:29:11) // at fetchPostBodyString (file /* @@ -184,8 +184,8 @@ testPerm({ net: true }, async function fetchRequest() { method: "POST", headers: [["Hello", "World"], ["Foo", "Bar"]] }); - assertEqual(response.status, 404); - assertEqual(response.headers.get("Content-Length"), "2"); + assertEquals(response.status, 404); + assertEquals(response.headers.get("Content-Length"), "2"); const actual = new TextDecoder().decode(buf.bytes()); const expected = [ @@ -194,7 +194,7 @@ testPerm({ net: true }, async function fetchRequest() { "foo: Bar\r\n", `host: ${addr}\r\n\r\n` ].join(""); - assertEqual(actual, expected); + assertEquals(actual, expected); }); testPerm({ net: true }, async function fetchPostBodyString() { @@ -206,8 +206,8 @@ testPerm({ net: true }, async function fetchPostBodyString() { headers: [["Hello", "World"], ["Foo", "Bar"]], body }); - assertEqual(response.status, 404); - assertEqual(response.headers.get("Content-Length"), "2"); + assertEquals(response.status, 404); + assertEquals(response.headers.get("Content-Length"), "2"); const actual = new TextDecoder().decode(buf.bytes()); const expected = [ @@ -218,7 +218,7 @@ testPerm({ net: true }, async function fetchPostBodyString() { `content-length: ${body.length}\r\n\r\n`, body ].join(""); - assertEqual(actual, expected); + assertEquals(actual, expected); }); testPerm({ net: true }, async function fetchPostBodyTypedArray() { @@ -231,8 +231,8 @@ testPerm({ net: true }, async function fetchPostBodyTypedArray() { headers: [["Hello", "World"], ["Foo", "Bar"]], body }); - assertEqual(response.status, 404); - assertEqual(response.headers.get("Content-Length"), "2"); + assertEquals(response.status, 404); + assertEquals(response.headers.get("Content-Length"), "2"); const actual = new TextDecoder().decode(buf.bytes()); const expected = [ @@ -243,6 +243,6 @@ testPerm({ net: true }, async function fetchPostBodyTypedArray() { `content-length: ${body.byteLength}\r\n\r\n`, bodyStr ].join(""); - assertEqual(actual, expected); + assertEquals(actual, expected); }); */ |