Last active
November 8, 2018 23:47
-
-
Save marcelmokos/7694e174bcfb0b4bacdf8cf8db6e8971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addDays(date = new Date(), days = 0) { | |
const dateClone = new Date(date); // date is an object provided by reference, we need to clone it | |
dateClone.setDate(date.getDate() + days); | |
return dateClone; | |
} | |
const tomorrowDate = (date, days = 1) => addDays(date, days); | |
it("Test tomorrowDate function", () => { | |
cosnt testDateString = "2018-01-01T00:00:00.000Z" | |
const testDate = new Date(testString); | |
const testTomorrowDate = new Date("2018-01-02T00:00:00.000Z"); | |
expect(yesterdayDate(testDateString).toIsoString()).toBe(testTomorrowDate.toIsoString()); | |
expect(yesterdayDate(testDate).toIsoString()).toBe(testTomorrowDate.toIsoString()); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment