Skip to content

Commit

Permalink
Merge pull request #756 from dynamoosejs/underlyingCustomType
Browse files Browse the repository at this point in the history
Adding test to ensure underlying type works for saving document
  • Loading branch information
fishcharlie committed Mar 22, 2020
2 parents a114a8f + a086faa commit e69151d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/Document.js
Expand Up @@ -289,6 +289,18 @@ describe("Document", () => {
}]);
});

it("Should save with correct object with custom type passed in as underlying type", async () => {
putItemFunction = () => Promise.resolve();
User = new Model("User", {"id": Number, "name": String, "birthday": Date}, {"create": false, "waitForActive": false});
const birthday = new Date();
user = new User({"id": 1, "name": "Charlie", "birthday": birthday.getTime()});
await callType.func(user).bind(user)();
expect(putParams).to.eql([{
"Item": {"id": {"N": "1"}, "name": {"S": "Charlie"}, "birthday": {"N": `${birthday.getTime()}`}},
"TableName": "User"
}]);
});

it("Should save with correct object with object type in schema", async () => {
putItemFunction = () => Promise.resolve();
User = new Model("User", {"id": Number, "address": {"type": Object, "schema": {"street": String, "country": {"type": String, "required": true}}}}, {"create": false, "waitForActive": false});
Expand Down

0 comments on commit e69151d

Please sign in to comment.