local dateFun = require("util.dateFunctions")

describe("Date Functions unit testing", function()
    it("should expand dates", function()
        assert.are.same(dateFun.expandDate("2015-01-01"), "January 1st, 2015")
        assert.are.same(dateFun.expandDate("2015-01-22"), "January 22nd, 2015")
        assert.are.same(dateFun.expandDate("2015-02-03"), "February 3rd, 2015")
        assert.are.same(dateFun.expandDate("2016-03-06"), "March 6th, 2016")
        assert.are.same(dateFun.expandDate("2016-04-09"), "April 9th, 2016")
        assert.are.same(dateFun.expandDate("2017-05-12"), "May 12th, 2017")
        assert.are.same(dateFun.expandDate("2017-06-15"), "June 15th, 2017")
        assert.are.same(dateFun.expandDate("2015-07-18"), "July 18th, 2015")
        assert.are.same(dateFun.expandDate("2015-08-21"), "August 21st, 2015")
        assert.are.same(dateFun.expandDate("2016-09-24"), "September 24th, 2016")
        assert.are.same(dateFun.expandDate("2016-10-27"), "October 27th, 2016")
        assert.are.same(dateFun.expandDate("2017-11-30"), "November 30th, 2017")
        assert.are.same(dateFun.expandDate("2017-12-31"), "December 31st, 2017")
    end)

    it("should verify date formatting and real date", function()
        assert.are.same(dateFun.verifyFormat("2015-12-23"), true)
        assert.are.same(dateFun.verifyFormat("2000-02-29"), true)
        assert.are.same(dateFun.verifyFormat("2015-02-29"), false)
        assert.are.same(dateFun.verifyFormat("2015-12-230230"), false)
        assert.are.same(dateFun.verifyFormat("1232015-12-23"), false)
        assert.are.same(dateFun.verifyFormat("2014-13-23"), false)
        assert.are.same(dateFun.verifyFormat("2014-00-23"), false)
        assert.are.same(dateFun.verifyFormat("2015-12-32"), false)
        assert.are.same(dateFun.verifyFormat("2015-01-32"), false)
        assert.are.same(dateFun.verifyFormat("2015-01-31"), true)
        assert.are.same(dateFun.verifyFormat("2015--1-32"), false)
    end)

    it("should check for valid dates", function()
        assert.are.same(dateFun.validDate("2015-12-23"), true)
        assert.are.same(dateFun.validDate("2015-11-23"), true)
        assert.are.same(dateFun.validDate("2015-11-20"), false)
        assert.are.same(dateFun.validDate("2000-02-29"), false)
        assert.are.same(dateFun.validDate("2015-02-29"), false)
        assert.are.same(dateFun.validDate("2015-12-230230"), false)
        assert.are.same(dateFun.validDate("1232015-12-23"), false)
        assert.are.same(dateFun.validDate("2014-13-23"), false)
        assert.are.same(dateFun.validDate("2014-00-23"), false)
        assert.are.same(dateFun.validDate("2015-12-32"), false)
        assert.are.same(dateFun.validDate("2015-01-32"), false)
        assert.are.same(dateFun.validDate("2015-01-31"), false)
        assert.are.same(dateFun.validDate("2015--1-32"), false)
        local currentDate = os.date("%F")
        assert.are.same(dateFun.validDate(currentDate), true)     
    end)
end)