Skip to content

Commit

Permalink
Changing tests to test to ensure expired objects are undefined instea…
Browse files Browse the repository at this point in the history
…d of null
  • Loading branch information
fishcharlie committed Mar 21, 2020
1 parent e88edca commit 21a3f0f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ describe("Document", () => {
{
"input": [{"id": 1, "ttl": 1}, {"type": "fromDynamo", "checkExpiredItem": true}],
"model": ["User", {"id": Number}, {"create": false, "waitForActive": false, "expires": {"ttl": 1000, "attribute": "ttl", "items": {"returnExpired": false}}}],
"output": null
"output": undefined
},
{
"input": [{"id": 1, "items": ["test"]}, {"type": "toDynamo", "saveUnknown": true}],
Expand Down
4 changes: 2 additions & 2 deletions test/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,11 @@ describe("Model", () => {
});
});

it("Should return null for expired object", async () => {
it("Should return undefined for expired object", async () => {
User = new dynamoose.Model("User", {"id": Number}, {"expires": {"ttl": 1000, "items": {"returnExpired": false}}});
getItemFunction = () => Promise.resolve({"Item": {"id": {"N": "1"}, "ttl": {"N": "1"}}});
const user = await callType.func(User).bind(User)(1);
expect(user).to.eql(null);
expect(user).to.eql(undefined);
});

it("Should return expired object if returnExpired is not set", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("Query", () => {
expect((await callType.func(Model.query("name").eq("Charlie").exec).bind(Model.query("name").eq("Charlie"))()).map((item) => ({...item}))).to.eql([{"id": 1, "name": "Charlie"}]);
});

it("Should return null for expired object", async () => {
it("Should return undefined for expired object", async () => {
queryPromiseResolver = () => ({"Items": [{"id": {"N": "1"}, "name": {"S": "Charlie"}, "ttl": {"N": "1"}}]});
Model = new dynamoose.Model("Cat", {"id": Number, "name": {"type": String, "index": {"global": true}}}, {"expires": {"ttl": 1000, "items": {"returnExpired": false}}});
expect((await callType.func(Model.query("name").eq("Charlie").exec).bind(Model.query("name").eq("Charlie"))()).map((item) => ({...item}))).to.eql([]);
Expand Down
2 changes: 1 addition & 1 deletion test/Scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("Scan", () => {
expect((await callType.func(Model.scan().exec).bind(Model.scan())()).map((item) => ({...item}))).to.eql([{"id": 1, "name": "Charlie"}]);
});

it("Should return null for expired object", async () => {
it("Should return undefined for expired object", async () => {
scanPromiseResolver = () => ({"Items": [{"id": {"N": "1"}, "ttl": {"N": "1"}}]});
Model = new dynamoose.Model("Cat", {"id": Number}, {"expires": {"ttl": 1000, "items": {"returnExpired": false}}});
expect((await callType.func(Model.scan().exec).bind(Model.scan())()).map((item) => ({...item}))).to.eql([]);
Expand Down

0 comments on commit 21a3f0f

Please sign in to comment.