| import { toEthiopicDate, toGregorianDate } from "../utils"; |
|
|
| import { addMonths } from "./addMonths"; |
|
|
| describe("addMonths", () => { |
| test("should add positive months correctly", () => { |
| |
| const date1 = toGregorianDate({ |
| year: 2016, |
| month: 4, |
| day: 22, |
| }); |
| const result1 = addMonths(date1, 2); |
| const ethResult1 = toEthiopicDate(result1); |
| expect(ethResult1).toEqual({ |
| year: 2016, |
| month: 6, |
| day: 22, |
| }); |
|
|
| |
| const date2 = toGregorianDate({ |
| year: 2016, |
| month: 5, |
| day: 22, |
| }); |
| const result2 = addMonths(date2, 3); |
| const ethResult2 = toEthiopicDate(result2); |
| expect(ethResult2).toEqual({ |
| year: 2016, |
| month: 8, |
| day: 22, |
| }); |
| }); |
|
|
| test("should add negative months correctly", () => { |
| |
| const date1 = toGregorianDate({ |
| year: 2016, |
| month: 4, |
| day: 21, |
| }); |
| const result1 = addMonths(date1, -2); |
| const ethResult1 = toEthiopicDate(result1); |
| expect(ethResult1).toEqual({ |
| year: 2016, |
| month: 2, |
| day: 21, |
| }); |
|
|
| |
| const date2 = toGregorianDate({ |
| year: 2016, |
| month: 4, |
| day: 21, |
| }); |
| const result2 = addMonths(date2, -3); |
| const ethResult2 = toEthiopicDate(result2); |
| expect(ethResult2).toEqual({ |
| year: 2016, |
| month: 1, |
| day: 21, |
| }); |
| }); |
|
|
| test("should handle day overflow in the 13th month Ethiopian calendar", () => { |
| |
| const date2 = toGregorianDate({ |
| year: 2016, |
| month: 12, |
| day: 25, |
| }); |
| const result2 = addMonths(date2, 1); |
| const ethResult2 = toEthiopicDate(result2); |
| expect(ethResult2).toEqual({ |
| year: 2016, |
| month: 13, |
| day: 5, |
| }); |
| }); |
| }); |
|
|