Skip to content

Commit

Permalink
Add test case for prefix and suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
youngkiu committed Oct 29, 2023
1 parent d08135b commit 5b59c07
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions packages/dynamoose/test/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,42 @@ describe("Transaction", () => {
});
});

it("Should send correct parameters to AWS by using the Model.transaction methods", async () => {
it("Should send correct parameters to AWS with Prefix and Suffix", async () => {
let transactParams = {};
dynamoose.aws.ddb.set({
"transactGetItems": (params) => {
transactParams = params;
return Promise.resolve({});
}
});

const User = dynamoose.model("User", {"id": Number, "name": String});
const Credit = dynamoose.model("Credit", {"id": Number, "name": String});
new dynamoose.Table("Table", [User, Credit], {"prefix": "MyApp_", "suffix": "_Table"});
await callType.func(dynamoose.transaction)([{"Get": {"Key": {"id": {"N": "1"}}, "TableName": "MyApp_Table_Table"}}, {"Get": {"Key": {"id": {"N": "2"}}, "TableName": "MyApp_Table_Table"}}]);
expect(transactParams).toEqual({
"TransactItems": [
{
"Get": {
"Key": {
"id": {"N": "1"}
},
"TableName": "MyApp_Table_Table"
}
},
{
"Get": {
"Key": {
"id": {"N": "2"}
},
"TableName": "MyApp_Table_Table"
}
}
]
});
});

it("Should send correct parameters to AWS by using the Model.transaction methods with Prefix", async () => {
let transactParams = {};
dynamoose.aws.ddb.set({
"transactGetItems": (params) => {
Expand Down Expand Up @@ -263,7 +298,7 @@ describe("Transaction", () => {
});
});

it("Should send correct parameters to AWS for put items by using the Model.transaction methods", async () => {
it("Should send correct parameters to AWS for put items by using the Model.transaction methods with Suffix", async () => {
let transactParams = {};
dynamoose.aws.ddb.set({
"transactWriteItems": (params) => {
Expand Down

0 comments on commit 5b59c07

Please sign in to comment.