Skip to content

Commit 95e5f7d

Browse files
author
Benjamin Lichtman
committed
Add and update tests
1 parent 906fbae commit 95e5f7d

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/testRunner/unittests/convertToAsyncFunction.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,15 @@ const [#|foo|] = function () {
11981198
function [#|f|]() {
11991199
return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
12001200
}
1201+
`);
1202+
1203+
_testConvertToAsyncFunction("convertToAsyncFunction_bindingPattern", `
1204+
function [#|f|]():Promise<void> {
1205+
return fetch('https://typescriptlang.org').then(res);
1206+
}
1207+
function res({ status, trailer }){
1208+
console.log(status);
1209+
}
12011210
`);
12021211

12031212
});

tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_InnerVarNameConflict.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ function /*[#|*/f/*|]*/(): Promise<string> {
1313
async function f(): Promise<string> {
1414
const resp = await fetch("https://typescriptlang.org");
1515
var blob = resp.blob().then(blob_1 => blob_1.byteOffset).catch(err => 'Error');
16+
const blob_2 = undefined;
1617
return blob_2.toString();
1718
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ==ORIGINAL==
2+
3+
function /*[#|*/f/*|]*/():Promise<void> {
4+
return fetch('https://typescriptlang.org').then(res);
5+
}
6+
function res({ status, trailer }){
7+
console.log(status);
8+
}
9+
10+
// ==ASYNC FUNCTION::Convert to async function==
11+
12+
async function f():Promise<void> {
13+
const __0 = await fetch('https://typescriptlang.org');
14+
return res(__0);
15+
}
16+
function res({ status, trailer }){
17+
console.log(status);
18+
}

0 commit comments

Comments
 (0)