Skip to content

Commit 7d38f43

Browse files
authored
test: merge API promise test cases with service import (#188)
1 parent de714dd commit 7d38f43

8 files changed

+104
-33
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import DynamoDB from "aws-sdk/clients/dynamodb";
2+
3+
const client = new DynamoDB();
4+
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+
}
14+
15+
// .then() and .catch()
16+
client
17+
.listTables()
18+
.promise()
19+
.then((data) => console.log(data))
20+
.catch((err) => console.log(err, err.stack));
21+
22+
// Client as class member
23+
class ClientClassMember {
24+
constructor(client = new 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+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { DynamoDB } from "@aws-sdk/client-dynamodb";
2+
3+
const client = new DynamoDB();
4+
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+
}

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)