-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement date converter * Refactor * Refactor more * Add tests
- Loading branch information
Showing
8 changed files
with
9,221 additions
and
8,990 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,93 @@ | ||
import DateConverter from './DateConverter' | ||
|
||
describe('DateConverter', () => { | ||
let babylonDate: DateConverter | ||
let mesopotamianDate: DateConverter | ||
|
||
beforeEach(() => { | ||
babylonDate = new DateConverter() | ||
mesopotamianDate = new DateConverter() | ||
}) | ||
|
||
test('Set modern date', () => { | ||
babylonDate.setToModernDate(-310, 3, 3) | ||
const expected = { | ||
year: -310, | ||
month: 3, | ||
year: -560, | ||
month: 4, | ||
day: 3, | ||
bcYear: '311', | ||
julianDay: 1607892, | ||
weekDay: 1, | ||
babylonianDay: 29, | ||
babylonianMonth: 11, | ||
babylonianRuler: '4 Alexander IV Aegus', | ||
seBabylonianYear: '0', | ||
seMacedonianYear: '1', | ||
arsacidYear: ' ', | ||
babylonianLunation: 5393, | ||
babylonianMonthLength: 29, | ||
bcYear: 561, | ||
cjdn: 1516611, | ||
weekDay: 7, | ||
mesopotamianDay: 28, | ||
mesopotamianMonth: 12, | ||
mesopotamianMonthLength: 30, | ||
ruler: 'Nebuchadnezzar II', | ||
regnalYear: 43, | ||
seBabylonianYear: -250, | ||
lunationNabonassar: 2302, | ||
} | ||
expect(babylonDate.calendar).toEqual(expected) | ||
mesopotamianDate.setToModernDate(-560, 4, 3) | ||
expect(mesopotamianDate.calendar).toEqual(expected) | ||
expect(mesopotamianDate.toModernDateString()).toEqual('3 April 561 BCE') | ||
}) | ||
|
||
test('Set Babylonian date', () => { | ||
// WiP. | ||
// ToDo: Update to properly test. | ||
babylonDate.setBabylonianDate(-200, 10, 1) | ||
test('Set Mesopotamian date', () => { | ||
const expected = { | ||
year: -625, | ||
month: 11, | ||
day: 27, | ||
bcYear: '626', | ||
julianDay: 1493107, | ||
weekDay: 2, | ||
babylonianDay: 1, | ||
babylonianMonth: 9, | ||
babylonianRuler: '1 Interregnum', | ||
seBabylonianYear: '-314', | ||
seMacedonianYear: ' ', | ||
arsacidYear: ' ', | ||
babylonianLunation: 1507, | ||
babylonianMonthLength: 30, | ||
year: -580, | ||
month: 1, | ||
day: 3, | ||
bcYear: 581, | ||
cjdn: 1509215, | ||
weekDay: 3, | ||
mesopotamianDay: 14, | ||
mesopotamianMonth: 10, | ||
mesopotamianMonthLength: 29, | ||
ruler: 'Nebuchadnezzar II', | ||
regnalYear: 23, | ||
lunationNabonassar: 2052, | ||
seBabylonianYear: -270, | ||
} | ||
mesopotamianDate.setMesopotamianDate('Nebuchadnezzar II', 23, 10, 14) | ||
expect(mesopotamianDate.calendar).toEqual(expected) | ||
expect(mesopotamianDate.toModernDateString()).toEqual('3 January 581 BCE') | ||
}) | ||
|
||
test('Set Seleucid date', () => { | ||
mesopotamianDate.setSeBabylonianDate(100, 12, 26) | ||
const expected = { | ||
lunationNabonassar: 6631, | ||
ruler: 'Antiochus III [the Great]', | ||
regnalYear: 11, | ||
bcYear: 211, | ||
day: 3, | ||
cjdn: 1644448, | ||
month: 4, | ||
seBabylonianYear: 100, | ||
seMacedonianYear: 101, | ||
seArsacidYear: 36, | ||
mesopotamianDay: 26, | ||
mesopotamianMonth: 12, | ||
mesopotamianMonthLength: 29, | ||
weekDay: 3, | ||
year: -210, | ||
} | ||
expect(babylonDate.calendar).toEqual(expected) | ||
expect(mesopotamianDate.calendar).toEqual(expected) | ||
expect(mesopotamianDate.toModernDateString()).toEqual('3 April 211 BCE') | ||
}) | ||
|
||
test('Offset year', () => { | ||
babylonDate.offsetYear(100) | ||
expect(babylonDate.calendar.year).toBe(-210) | ||
mesopotamianDate.offsetYear(100) | ||
expect(mesopotamianDate.calendar.year).toBe(-210) | ||
expect(mesopotamianDate.toModernDateString()).toEqual('3 March 211 BCE') | ||
}) | ||
|
||
test('Offset month', () => { | ||
babylonDate.offsetMonth(5) | ||
expect(babylonDate.calendar.month).toBe(8) | ||
expect(babylonDate.calendar.year).toBe(-310) | ||
mesopotamianDate.offsetMonth(5) | ||
expect(mesopotamianDate.calendar.month).toBe(8) | ||
expect(mesopotamianDate.calendar.year).toBe(-310) | ||
expect(mesopotamianDate.toModernDateString()).toEqual('3 August 311 BCE') | ||
}) | ||
|
||
test('Offset day', () => { | ||
babylonDate.offsetDay(10) | ||
expect(babylonDate.calendar.day).toBe(13) | ||
}) | ||
|
||
test('Get current day', () => { | ||
babylonDate.calendar.day = 25 | ||
expect(babylonDate.getCurrentDay()).toBe(25) | ||
mesopotamianDate.offsetDay(10) | ||
expect(mesopotamianDate.calendar.day).toBe(13) | ||
expect(mesopotamianDate.toModernDateString()).toEqual('13 March 311 BCE') | ||
}) | ||
}) |
Oops, something went wrong.