Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
5c2e499c
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
5c2e499c
编写于
9月 21, 2020
作者:
L
Luca Casonato
提交者:
GitHub
9月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: Response.arrayBuffer() doesn't return promise (#7618)
上级
92edc364
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
1 deletion
+53
-1
cli/tests/unit/response_test.ts
cli/tests/unit/response_test.ts
+51
-0
cli/tests/unit/unit_tests.ts
cli/tests/unit/unit_tests.ts
+1
-0
op_crates/fetch/26_fetch.js
op_crates/fetch/26_fetch.js
+1
-1
未找到文件。
cli/tests/unit/response_test.ts
0 → 100644
浏览文件 @
5c2e499c
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import
{
unitTest
,
assert
,
assertEquals
}
from
"
./test_util.ts
"
;
unitTest
(
async
function
responseText
()
{
const
response
=
new
Response
(
"
hello world
"
);
const
textPromise
=
response
.
text
();
assert
(
textPromise
instanceof
Promise
);
const
text
=
await
textPromise
;
assert
(
typeof
text
===
"
string
"
);
assertEquals
(
text
,
"
hello world
"
);
});
unitTest
(
async
function
responseArrayBuffer
()
{
const
response
=
new
Response
(
new
Uint8Array
([
1
,
2
,
3
]));
const
arrayBufferPromise
=
response
.
arrayBuffer
();
assert
(
arrayBufferPromise
instanceof
Promise
);
const
arrayBuffer
=
await
arrayBufferPromise
;
assert
(
arrayBuffer
instanceof
ArrayBuffer
);
assertEquals
(
new
Uint8Array
(
arrayBuffer
),
new
Uint8Array
([
1
,
2
,
3
]));
});
unitTest
(
async
function
responseJson
()
{
const
response
=
new
Response
(
'
{"hello": "world"}
'
);
const
jsonPromise
=
response
.
json
();
assert
(
jsonPromise
instanceof
Promise
);
const
json
=
await
jsonPromise
;
assert
(
json
instanceof
Object
);
assertEquals
(
json
,
{
hello
:
"
world
"
});
});
unitTest
(
async
function
responseBlob
()
{
const
response
=
new
Response
(
new
Uint8Array
([
1
,
2
,
3
]));
const
blobPromise
=
response
.
blob
();
assert
(
blobPromise
instanceof
Promise
);
const
blob
=
await
blobPromise
;
assert
(
blob
instanceof
Blob
);
assertEquals
(
blob
,
new
Blob
([
new
Uint8Array
([
1
,
2
,
3
])]));
});
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
);
});
cli/tests/unit/unit_tests.ts
浏览文件 @
5c2e499c
...
...
@@ -54,6 +54,7 @@ import "./remove_test.ts";
import
"
./rename_test.ts
"
;
import
"
./request_test.ts
"
;
import
"
./resources_test.ts
"
;
import
"
./response_test.ts
"
;
import
"
./signal_test.ts
"
;
import
"
./stat_test.ts
"
;
import
"
./stdio_test.ts
"
;
...
...
op_crates/fetch/26_fetch.js
浏览文件 @
5c2e499c
...
...
@@ -869,7 +869,7 @@
if
(
this
.
_bodySource
instanceof
ReadableStream
)
{
return
bufferFromStream
(
this
.
_bodySource
.
getReader
(),
this
.
#
size
);
}
return
bodyToArrayBuffer
(
this
.
_bodySource
);
return
Promise
.
resolve
(
bodyToArrayBuffer
(
this
.
_bodySource
)
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录