Skip to content

Commit de714dd

Browse files
authored
test: merge API promise test cases in a single file (#187)
1 parent 2154067 commit de714dd

8 files changed

+94
-109
lines changed

src/transforms/v2-to-v3/__fixtures__/api-await.input.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/transforms/v2-to-v3/__fixtures__/api-await.output.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/transforms/v2-to-v3/__fixtures__/api-promise-class-member.input.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/transforms/v2-to-v3/__fixtures__/api-promise-class-member.output.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/transforms/v2-to-v3/__fixtures__/api-promise-variable-declarator.input.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/transforms/v2-to-v3/__fixtures__/api-promise-variable-declarator.output.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/transforms/v2-to-v3/__fixtures__/api-promise.input.js

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,52 @@ import AWS from "aws-sdk";
22

33
const client = new AWS.DynamoDB();
44

5-
client
6-
.listTables()
7-
.promise()
8-
.then((data) => console.log(data))
9-
.catch((err) => console.log(err, err.stack));
5+
// Promise without params
6+
{
7+
// async/await
8+
try {
9+
await client.listTables().promise();
10+
console.log(data);
11+
} catch (err) {
12+
console.log(err, err.stack);
13+
}
1014

11-
client
12-
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
13-
.promise()
14-
.then((data) => console.log(data))
15-
.catch((err) => console.log(err, err.stack));
15+
// .then() and .catch()
16+
client
17+
.listTables()
18+
.promise()
19+
.then((data) => console.log(data))
20+
.catch((err) => console.log(err, err.stack));
1621

22+
// Client as class member
23+
class ClientClassMember {
24+
constructor(client = new AWS.DynamoDB()) {
25+
this.client = client;
26+
}
27+
28+
async listTables() {
29+
return await this.client.listTables().promise();
30+
}
31+
}
32+
33+
// Variable declarator
34+
const listTablesPromise = client.listTables().promise();
35+
}
36+
37+
// Promise with params
38+
{
39+
// async/await
40+
try {
41+
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
42+
console.log(data);
43+
} catch (err) {
44+
console.log(err, err.stack);
45+
}
46+
47+
// .then() and .catch()
48+
client
49+
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
50+
.promise()
51+
.then((data) => console.log(data))
52+
.catch((err) => console.log(err, err.stack));
53+
}

src/transforms/v2-to-v3/__fixtures__/api-promise.output.js

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,50 @@ import { DynamoDB } from "@aws-sdk/client-dynamodb";
22

33
const client = new DynamoDB();
44

5-
client
6-
.listTables()
7-
.then((data) => console.log(data))
8-
.catch((err) => console.log(err, err.stack));
9-
10-
client
11-
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
12-
.then((data) => console.log(data))
13-
.catch((err) => console.log(err, err.stack));
5+
// Promise without params
6+
{
7+
// async/await
8+
try {
9+
await client.listTables();
10+
console.log(data);
11+
} catch (err) {
12+
console.log(err, err.stack);
13+
}
14+
15+
// .then() and .catch()
16+
client
17+
.listTables()
18+
.then((data) => console.log(data))
19+
.catch((err) => console.log(err, err.stack));
20+
21+
// Client as class member
22+
class ClientClassMember {
23+
constructor(client = new DynamoDB()) {
24+
this.client = client;
25+
}
26+
27+
async listTables() {
28+
return await this.client.listTables();
29+
}
30+
}
31+
32+
// Variable declarator
33+
const listTablesPromise = client.listTables();
34+
}
35+
36+
// Promise with params
37+
{
38+
// async/await
39+
try {
40+
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
41+
console.log(data);
42+
} catch (err) {
43+
console.log(err, err.stack);
44+
}
45+
46+
// .then() and .catch()
47+
client
48+
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
49+
.then((data) => console.log(data))
50+
.catch((err) => console.log(err, err.stack));
51+
}

0 commit comments

Comments
 (0)