Skip to content

Commit

Permalink
Adding test for race condition if update types passed into Model.upda…
Browse files Browse the repository at this point in the history
…te with multiple updates in one object
  • Loading branch information
fishcharlie committed Mar 21, 2020
1 parent a73f715 commit f0cbad1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/Model.js
Expand Up @@ -1307,6 +1307,34 @@ describe("Model", () => {
});
});

it("Should send correct params to updateItem with $SET update expression and multiple property updates", async () => {
updateItemFunction = () => Promise.resolve({});
await callType.func(User).bind(User)({"id": 1}, {"$SET": {"name": "Charlie", "age": 5}});
expect(updateItemParams).to.be.an("object");
expect(updateItemParams).to.eql({
"ExpressionAttributeNames": {
"#a0": "name",
"#a1": "age"
},
"ExpressionAttributeValues": {
":v0": {
"S": "Charlie"
},
":v1": {
"N": "5"
}
},
"UpdateExpression": "SET #a0 = :v0, #a1 = :v1",
"Key": {
"id": {
"N": "1"
}
},
"TableName": "User",
"ReturnValues": "ALL_NEW"
});
});

it("Should send correct params to updateItem with $SET update expression for list", async () => {
updateItemFunction = () => Promise.resolve({});
User = new dynamoose.Model("User", {"id": Number, "friends": {"type": Array, "schema": [String]}});
Expand Down

0 comments on commit f0cbad1

Please sign in to comment.