From 2bb4aa17d1881d2ddcdad1f83c2f6a8c2f02b7ca Mon Sep 17 00:00:00 2001 From: Ilya Khait Date: Tue, 21 Jan 2025 16:37:02 +0000 Subject: [PATCH] Format tests --- src/chronology/domain/Date.test.ts | 445 ++++++++++++++--------------- 1 file changed, 221 insertions(+), 224 deletions(-) diff --git a/src/chronology/domain/Date.test.ts b/src/chronology/domain/Date.test.ts index 6c4d82fcb..2fdacb430 100644 --- a/src/chronology/domain/Date.test.ts +++ b/src/chronology/domain/Date.test.ts @@ -85,285 +85,282 @@ describe('MesopotamianDate', () => { expect(date.isAssyrianDate).toBeUndefined() expect(date.ur3Calendar).toBeUndefined() }) - - describe('converts to string', () => { - it('returns the correct string representation (standard)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '12' }, - king, - }) - expect(date.toString()).toBe('12.V.10 Sargon (ca. 2325 BCE PJC)') - }) - }) - - it('returns the correct string representation (Seleucid)', () => { + }) + describe('converts to string', () => { + it('returns the correct string representation (standard)', () => { const date = new MesopotamianDate({ year: { value: '10' }, month: { value: '5' }, day: { value: '12' }, - isSeleucidEra: true, + king, }) - expect(date.toString()).toBe( - '12.V.10 SE (30 August 302 BCE PJC | 25 August 302 BCE PGC)' - ) + expect(date.toString()).toBe('12.V.10 Sargon (ca. 2325 BCE PJC)') }) + }) - it('returns the correct string representation (Seleucid, no day)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '' }, - isSeleucidEra: true, - }) - expect(date.toString()).toBe( - '∅.V.10 SE (ca. 19 August - 16 September 302 BCE PJC | ca. 14 August - 11 September 302 BCE PGC)' - ) + it('returns the correct string representation (Seleucid)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '5' }, + day: { value: '12' }, + isSeleucidEra: true, }) + expect(date.toString()).toBe( + '12.V.10 SE (30 August 302 BCE PJC | 25 August 302 BCE PGC)' + ) + }) - it('returns the correct string representation (Seleucid, no month)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '' }, - day: { value: '12' }, - isSeleucidEra: true, - }) - expect(date.toString()).toBe( - '12.∅.10 SE (ca. 4 May 302 - 24 March 301 BCE PJC | ca. 29 April 302 - 20 March 301 BCE PGC)' - ) + it('returns the correct string representation (Seleucid, no day)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '5' }, + day: { value: '' }, + isSeleucidEra: true, }) + expect(date.toString()).toBe( + '∅.V.10 SE (ca. 19 August - 16 September 302 BCE PJC | ca. 14 August - 11 September 302 BCE PGC)' + ) + }) - it('returns the correct string representation (Seleucid, no year)', () => { - const date = new MesopotamianDate({ - year: { value: '' }, - month: { value: '5' }, - day: { value: '12' }, - isSeleucidEra: true, - }) - expect(date.toString()).toBe('12.V.∅ SE') + it('returns the correct string representation (Seleucid, no month)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '' }, + day: { value: '12' }, + isSeleucidEra: true, }) + expect(date.toString()).toBe( + '12.∅.10 SE (ca. 4 May 302 - 24 March 301 BCE PJC | ca. 29 April 302 - 20 March 301 BCE PGC)' + ) + }) - it('returns the correct string representation (Nabonassar era)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '12' }, - king: nabonassarEraKing, - isSeleucidEra: false, - }) - expect(date.toString()).toBe( - '12.V.10 Darius I (11 August 512 BCE PJC | 5 August 512 BCE PGC)' - ) + it('returns the correct string representation (Seleucid, no year)', () => { + const date = new MesopotamianDate({ + year: { value: '' }, + month: { value: '5' }, + day: { value: '12' }, + isSeleucidEra: true, }) + expect(date.toString()).toBe('12.V.∅ SE') + }) - it('returns the correct string representation (Nabonassar era, no year)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '' }, - king: nabonassarEraKing, - isSeleucidEra: false, - }) - expect(date.toString()).toBe( - '∅.V.10 Darius I (ca. 31 July - 29 August 512 BCE PJC | ca. 25 July - 23 August 512 BCE PGC)' - ) + it('returns the correct string representation (Nabonassar era)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '5' }, + day: { value: '12' }, + king: nabonassarEraKing, + isSeleucidEra: false, }) + expect(date.toString()).toBe( + '12.V.10 Darius I (11 August 512 BCE PJC | 5 August 512 BCE PGC)' + ) + }) - it('returns the correct string representation (Nabonassar era, no month)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '' }, - day: { value: '12' }, - king: nabonassarEraKing, - isSeleucidEra: false, - }) - expect(date.toString()).toBe( - '12.∅.10 Darius I (ca. 16 April 512 - 6 March 511 BCE PJC | ca. 10 April 512 - 28 February 511 BCE PGC)' - ) + it('returns the correct string representation (Nabonassar era, no year)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '5' }, + day: { value: '' }, + king: nabonassarEraKing, + isSeleucidEra: false, }) + expect(date.toString()).toBe( + '∅.V.10 Darius I (ca. 31 July - 29 August 512 BCE PJC | ca. 25 July - 23 August 512 BCE PGC)' + ) + }) - it('returns the correct string representation (Nabonassar era, no day)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '' }, - king: nabonassarEraKing, - isSeleucidEra: false, - }) - expect(date.toString()).toBe( - '∅.V.10 Darius I (ca. 31 July - 29 August 512 BCE PJC | ca. 25 July - 23 August 512 BCE PGC)' - ) + it('returns the correct string representation (Nabonassar era, no month)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '' }, + day: { value: '12' }, + king: nabonassarEraKing, + isSeleucidEra: false, }) + expect(date.toString()).toBe( + '12.∅.10 Darius I (ca. 16 April 512 - 6 March 511 BCE PJC | ca. 10 April 512 - 28 February 511 BCE PGC)' + ) + }) - it('returns the correct string representation (Nabonassar era, king only)', () => { - const date = new MesopotamianDate({ - year: { value: '' }, - month: { value: '' }, - day: { value: '' }, - king: nabonassarEraKing, - isSeleucidEra: false, - }) - expect(date.toString()).toBe( - 'Darius I (ca. 14 April 521 - 5 April 485 BCE PJC | ca. 8 April 521 - 31 March 485 BCE PGC)' - ) + it('returns the correct string representation (Nabonassar era, no day)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '5' }, + day: { value: '' }, + king: nabonassarEraKing, + isSeleucidEra: false, }) + expect(date.toString()).toBe( + '∅.V.10 Darius I (ca. 31 July - 29 August 512 BCE PJC | ca. 25 July - 23 August 512 BCE PGC)' + ) + }) - it('returns the correct string representation (Ur III)', () => { - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '12' }, - king: kingUr3, - ur3Calendar: Ur3Calendar.UR, - }) - expect(date.toString()).toBe( - '12.V.10 Amar-Suen, Ur calendar (ca. 2035 BCE PJC)' - ) + it('returns the correct string representation (Nabonassar era, king only)', () => { + const date = new MesopotamianDate({ + year: { value: '' }, + month: { value: '' }, + day: { value: '' }, + king: nabonassarEraKing, + isSeleucidEra: false, }) + expect(date.toString()).toBe( + 'Darius I (ca. 14 April 521 - 5 April 485 BCE PJC | ca. 8 April 521 - 31 March 485 BCE PGC)' + ) + }) - it('returns the correct string representation (Assyrian date with eponym)', () => { - const date = new MesopotamianDate({ - year: { value: '1' }, - month: { value: '1' }, - day: { value: '1' }, - isAssyrianDate: true, - eponym, - }) - - expect(date.toString()).toBe( - '1.I.1 Adad-nērārī (II) (NA eponym) (ca. 910 BCE PJC)' - ) + it('returns the correct string representation (Ur III)', () => { + const date = new MesopotamianDate({ + year: { value: '10' }, + month: { value: '5' }, + day: { value: '12' }, + king: kingUr3, + ur3Calendar: Ur3Calendar.UR, }) + expect(date.toString()).toBe( + '12.V.10 Amar-Suen, Ur calendar (ca. 2035 BCE PJC)' + ) + }) - it('returns the correct string representation (empty)', () => { - const date = new MesopotamianDate({ - year: { value: '' }, - month: { value: '' }, - day: { value: '' }, - king, - }) - expect(date.toString()).toBe('Sargon (ca. 2334–2279 BCE PJC)') + it('returns the correct string representation (Assyrian date with eponym)', () => { + const date = new MesopotamianDate({ + year: { value: '1' }, + month: { value: '1' }, + day: { value: '1' }, + isAssyrianDate: true, + eponym, }) - it('returns the correct string representation (empty, uncertain)', () => { - const date = new MesopotamianDate({ - year: { value: '', isUncertain: true }, - month: { value: '' }, - day: { value: '' }, - king, - }) - expect(date.toString()).toBe('∅.∅.∅? Sargon (ca. 2334–2279 BCE PJC)') - }) + expect(date.toString()).toBe( + '1.I.1 Adad-nērārī (II) (NA eponym) (ca. 910 BCE PJC)' + ) + }) - it('returns the correct string representation (broken, missing)', () => { - const date = new MesopotamianDate({ - year: { value: '', isBroken: true }, - month: { value: '', isBroken: true, isIntercalary: true }, - day: { value: '', isBroken: true }, - king, - }) - expect(date.toString()).toBe( - '[x].[x]².[x] Sargon (ca. 2334–2279 BCE PJC)' - ) + it('returns the correct string representation (empty)', () => { + const date = new MesopotamianDate({ + year: { value: '' }, + month: { value: '' }, + day: { value: '' }, + king, }) + expect(date.toString()).toBe('Sargon (ca. 2334–2279 BCE PJC)') + }) - it('returns the correct string representation (broken, reconstructed)', () => { - const date = new MesopotamianDate({ - year: { value: '1', isBroken: true }, - month: { value: '2', isBroken: true, isIntercalary: true }, - day: { value: '3', isBroken: true }, - king, - }) - expect(date.toString()).toBe('[3].[II²].[1] Sargon (ca. 2334 BCE PJC)') + it('returns the correct string representation (empty, uncertain)', () => { + const date = new MesopotamianDate({ + year: { value: '', isUncertain: true }, + month: { value: '' }, + day: { value: '' }, + king, }) + expect(date.toString()).toBe('∅.∅.∅? Sargon (ca. 2334–2279 BCE PJC)') + }) - it('returns the correct string representation (uncertain)', () => { - const date = new MesopotamianDate({ - year: { value: '1', isUncertain: true }, - month: { value: '2', isUncertain: true, isIntercalary: true }, - day: { value: '3', isUncertain: true }, - king, - }) - expect(date.toString()).toBe('3?.II²?.1? Sargon (ca. 2334 BCE PJC)') + it('returns the correct string representation (broken, missing)', () => { + const date = new MesopotamianDate({ + year: { value: '', isBroken: true }, + month: { value: '', isBroken: true, isIntercalary: true }, + day: { value: '', isBroken: true }, + king, }) + expect(date.toString()).toBe('[x].[x]².[x] Sargon (ca. 2334–2279 BCE PJC)') + }) - it('returns the correct string representation (broken and uncertain)', () => { - const date = new MesopotamianDate({ - year: { value: '1', isBroken: true, isUncertain: true }, - month: { - value: '2', - isBroken: true, - isUncertain: true, - isIntercalary: true, - }, - day: { value: '3', isBroken: true, isUncertain: true }, - king, - }) - expect(date.toString()).toBe('[3]?.[II²]?.[1]? Sargon (ca. 2334 BCE PJC)') + it('returns the correct string representation (broken, reconstructed)', () => { + const date = new MesopotamianDate({ + year: { value: '1', isBroken: true }, + month: { value: '2', isBroken: true, isIntercalary: true }, + day: { value: '3', isBroken: true }, + king, }) + expect(date.toString()).toBe('[3].[II²].[1] Sargon (ca. 2334 BCE PJC)') + }) - describe('toJulianDate branching', () => { - it('returns empty when none of the conditions are met', () => { - const date = new MesopotamianDate({ - year: { value: '1' }, - month: { value: '1' }, - day: { value: '1' }, - }) - expect(date.toModernDate()).toBe('') - }) + it('returns the correct string representation (uncertain)', () => { + const date = new MesopotamianDate({ + year: { value: '1', isUncertain: true }, + month: { value: '2', isUncertain: true, isIntercalary: true }, + day: { value: '3', isUncertain: true }, + king, + }) + expect(date.toString()).toBe('3?.II²?.1? Sargon (ca. 2334 BCE PJC)') + }) - it('returns the correct modern date for a king without orderGlobal', () => { - const unorderedKing = { ...king, orderGlobal: -1 } - const date = new MesopotamianDate({ - year: { value: '10' }, - month: { value: '5' }, - day: { value: '12' }, - king: unorderedKing, - }) - expect(date.toModernDate()).toBe('ca. 2325 BCE PJC') - }) + it('returns the correct string representation (broken and uncertain)', () => { + const date = new MesopotamianDate({ + year: { value: '1', isBroken: true, isUncertain: true }, + month: { + value: '2', + isBroken: true, + isUncertain: true, + isIntercalary: true, + }, + day: { value: '3', isBroken: true, isUncertain: true }, + king, }) + expect(date.toString()).toBe('[3]?.[II²]?.[1]? Sargon (ca. 2334 BCE PJC)') + }) - it('handles king with orderGlobal matching rulerToBrinkmanKings', () => { - const kingWithSpecificOrder = { ...king, orderGlobal: 1 } + describe('toJulianDate branching', () => { + it('returns empty when none of the conditions are met', () => { const date = new MesopotamianDate({ year: { value: '1' }, month: { value: '1' }, day: { value: '1' }, - king: kingWithSpecificOrder, }) - const result = date.toModernDate() - expect(result).toBe('ca. 2334 BCE PJC') + expect(date.toModernDate()).toBe('') }) - it('handles king without a date', () => { - const kingWithoutDate = { ...king, date: '' } + it('returns the correct modern date for a king without orderGlobal', () => { + const unorderedKing = { ...king, orderGlobal: -1 } const date = new MesopotamianDate({ - year: { value: '1' }, - month: { value: '1' }, - day: { value: '1' }, - king: kingWithoutDate, + year: { value: '10' }, + month: { value: '5' }, + day: { value: '12' }, + king: unorderedKing, }) - expect(date.toModernDate()).toBe('') + expect(date.toModernDate()).toBe('ca. 2325 BCE PJC') }) }) - describe('handles king date with non-numeric characters', () => { - it('parses and processes king date correctly', () => { - const kingWithDirtyDate = { - ...king, - date: 'c. 818–c. 813', - } + it('handles king with orderGlobal matching rulerToBrinkmanKings', () => { + const kingWithSpecificOrder = { ...king, orderGlobal: 1 } + const date = new MesopotamianDate({ + year: { value: '1' }, + month: { value: '1' }, + day: { value: '1' }, + king: kingWithSpecificOrder, + }) + const result = date.toModernDate() + expect(result).toBe('ca. 2334 BCE PJC') + }) - const date = new MesopotamianDate({ - year: { value: '5' }, - month: { value: '3' }, - day: { value: '10' }, - king: kingWithDirtyDate, - }) + it('handles king without a date', () => { + const kingWithoutDate = { ...king, date: '' } + const date = new MesopotamianDate({ + year: { value: '1' }, + month: { value: '1' }, + day: { value: '1' }, + king: kingWithoutDate, + }) + expect(date.toModernDate()).toBe('') + }) +}) - expect(date.toModernDate()).toBe('ca. 814 BCE PJC') +describe('handles king date with non-numeric characters', () => { + it('parses and processes king date correctly', () => { + const kingWithDirtyDate = { + ...king, + date: 'c. 818–c. 813', + } + + const date = new MesopotamianDate({ + year: { value: '5' }, + month: { value: '3' }, + day: { value: '10' }, + king: kingWithDirtyDate, }) + + expect(date.toModernDate()).toBe('ca. 814 BCE PJC') }) })