define(["require", "exports", "./DateMath"], function (require, exports, DateMath) {
    "use strict";
    var expect = chai.expect;
    var Months;
    (function (Months) {
        Months[Months["Jan"] = 0] = "Jan";
        Months[Months["Feb"] = 1] = "Feb";
        Months[Months["Mar"] = 2] = "Mar";
        Months[Months["Apr"] = 3] = "Apr";
        Months[Months["May"] = 4] = "May";
        Months[Months["Jun"] = 5] = "Jun";
        Months[Months["Jul"] = 6] = "Jul";
        Months[Months["Aug"] = 7] = "Aug";
        Months[Months["Sep"] = 8] = "Sep";
        Months[Months["Oct"] = 9] = "Oct";
        Months[Months["Nov"] = 10] = "Nov";
        Months[Months["Dec"] = 11] = "Dec";
    })(Months || (Months = {}));
    describe('DateMath', function () {
        it('can add days', function () {
            var startDate = new Date(2016, Months.Apr, 1);
            var result = DateMath.addDays(startDate, 5);
            var expected = new Date(2016, Months.Apr, 6);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can add days across a month boundary', function () {
            var startDate = new Date(2016, Months.Mar, 30);
            var result = DateMath.addDays(startDate, 5);
            var expected = new Date(2016, Months.Apr, 4);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can add days across multiple month boundaries', function () {
            var startDate = new Date(2016, Months.Mar, 31);
            var result = DateMath.addDays(startDate, 65);
            var expected = new Date(2016, Months.Jun, 4);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can add days across leap day boundaries', function () {
            var startDate = new Date(2016, Months.Feb, 28);
            var result = DateMath.addDays(startDate, 2);
            var expected = new Date(2016, Months.Mar, 1);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can add months', function () {
            var startDate = new Date(2015, Months.Dec, 31);
            var result = DateMath.addMonths(startDate, 1);
            var expected = new Date(2016, Months.Jan, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 2);
            expected = new Date(2016, Months.Feb, 29);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 3);
            expected = new Date(2016, Months.Mar, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 4);
            expected = new Date(2016, Months.Apr, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 5);
            expected = new Date(2016, Months.May, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 6);
            expected = new Date(2016, Months.Jun, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 7);
            expected = new Date(2016, Months.Jul, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 8);
            expected = new Date(2016, Months.Aug, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 9);
            expected = new Date(2016, Months.Sep, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 10);
            expected = new Date(2016, Months.Oct, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 11);
            expected = new Date(2016, Months.Nov, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 12);
            expected = new Date(2016, Months.Dec, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, 14);
            expected = new Date(2017, Months.Feb, 28);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can add years', function () {
            var startDate = new Date(2016, Months.Feb, 29);
            var result = DateMath.addYears(startDate, 1);
            var expected = new Date(2017, Months.Feb, 28);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            startDate = new Date(2016, Months.Feb, 29);
            result = DateMath.addYears(startDate, 4);
            expected = new Date(2020, Months.Feb, 29);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            startDate = new Date(2016, Months.Jan, 1);
            result = DateMath.addYears(startDate, 1);
            expected = new Date(2017, Months.Jan, 1);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can subtract days', function () {
            var startDate = new Date(2016, Months.Apr, 30);
            var result = DateMath.addDays(startDate, -5);
            var expected = new Date(2016, Months.Apr, 25);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can subtract days across a month boundry', function () {
            var startDate = new Date(2016, Months.Apr, 1);
            var result = DateMath.addDays(startDate, -5);
            var expected = new Date(2016, Months.Mar, 27);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can subtract days across multiple month boundaries', function () {
            var startDate = new Date(2016, Months.Jul, 4);
            var result = DateMath.addDays(startDate, -65);
            var expected = new Date(2016, Months.Apr, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can subtract days across leap day boundaries', function () {
            var startDate = new Date(2016, Months.Mar, 1);
            var result = DateMath.addDays(startDate, -2);
            var expected = new Date(2016, Months.Feb, 28);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can subtract months', function () {
            var startDate = new Date(2016, Months.Dec, 31);
            var result = DateMath.addMonths(startDate, -12);
            var expected = new Date(2015, Months.Dec, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -11);
            expected = new Date(2016, Months.Jan, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -10);
            expected = new Date(2016, Months.Feb, 29);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -9);
            expected = new Date(2016, Months.Mar, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -8);
            expected = new Date(2016, Months.Apr, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -7);
            expected = new Date(2016, Months.May, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -6);
            expected = new Date(2016, Months.Jun, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -5);
            expected = new Date(2016, Months.Jul, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -4);
            expected = new Date(2016, Months.Aug, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -3);
            expected = new Date(2016, Months.Sep, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -2);
            expected = new Date(2016, Months.Oct, 31);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -1);
            expected = new Date(2016, Months.Nov, 30);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            result = DateMath.addMonths(startDate, -22);
            expected = new Date(2015, Months.Feb, 28);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can subtract years', function () {
            var startDate = new Date(2016, Months.Feb, 29);
            var result = DateMath.addYears(startDate, -1);
            var expected = new Date(2015, Months.Feb, 28);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            startDate = new Date(2016, Months.Feb, 29);
            result = DateMath.addYears(startDate, -4);
            expected = new Date(2012, Months.Feb, 29);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            startDate = new Date(2016, Months.Jan, 1);
            result = DateMath.addYears(startDate, -1);
            expected = new Date(2015, Months.Jan, 1);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can set the month', function () {
            var startDate = new Date(2016, Months.Jan, 31);
            var result = DateMath.setMonth(startDate, Months.Feb);
            var expected = new Date(2016, Months.Feb, 29);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
            startDate = new Date(2016, Months.Jun, 1);
            result = DateMath.setMonth(startDate, Months.Feb);
            expected = new Date(2016, Months.Feb, 1);
            expect(result.getTime(), result.toDateString()).to.be.equal(expected.getTime());
        });
        it('can compare dates', function () {
            var date1 = new Date(2016, 4, 1);
            var date2 = new Date(2016, 4, 1);
            expect(DateMath.compareDates(date1, date2)).to.be.true;
            date1 = new Date(2016, 4, 1, 12, 30, 0);
            date2 = new Date(2016, 4, 1, 10, 0, 0);
            expect(DateMath.compareDates(date1, date2)).to.be.true;
            date1 = new Date(2016, 4, 1);
            date2 = new Date(2016, 4, 2);
            expect(DateMath.compareDates(date1, date2)).to.be.false;
            date1 = new Date(2016, 4, 1);
            date2 = new Date(2016, 5, 1);
            expect(DateMath.compareDates(date1, date2)).to.be.false;
            date1 = new Date(2016, 4, 1);
            date2 = new Date(2017, 4, 1);
            expect(DateMath.compareDates(date1, date2)).to.be.false;
        });
    });
});

//# sourceMappingURL=DateMath.test.js.map
