diff --git a/__tests__/index.test.js b/__tests__/index.test.js index 37f7c5d..7f210d4 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -26,6 +26,14 @@ describe("time utilities", () => { expect(util.time.nowFormatted('YYYY-MM-dd HH:mm:ss')).toEqual("2021-02-01T00:00:00.000Z"); spied.mockRestore(); }); + test("nowISO8601", async () => { + // patch date utilities to ensure consistency + const newDate = new Date(Date.UTC(2021, 1, 1)); + const spied = jest.spyOn(global, 'Date').mockImplementation(() => newDate); + + expect(util.time.nowISO8601()).toEqual("2021-02-01T00:00:00.000Z"); + spied.mockRestore(); + }); }); describe("dynamodb helpers", () => { diff --git a/index.js b/index.js index d084990..ebbf7f6 100644 --- a/index.js +++ b/index.js @@ -128,6 +128,9 @@ export const util = { // TODO: not completely correct, but close enough probably return new Date().toISOString(); }, + nowISO8601: function() { + return new Date().toISOString(); + }, }, transform: { toDynamoDBFilterExpression: function(value) {