From 20d69469a4c80a196de23625d0420487b0ed04a6 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Thu, 29 Dec 2022 16:17:39 +1100 Subject: Show event-count data on timeline Backend: Send event-count data to client in EventResponse instance Fix certain usages of gregorian calendar instead of julian Move HistDate, SCALES, etc, into cal.py Frontend: Make App update a unitCountMaps object using event-count data from server Make TimeLine show visual indication of unit counts Add showEventCounts option to store Update unit tests --- tests/lib.test.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/lib.test.ts b/tests/lib.test.ts index 9421ca1..85e17bc 100644 --- a/tests/lib.test.ts +++ b/tests/lib.test.ts @@ -1,8 +1,8 @@ import {moduloPositive, gregorianToJdn, julianToJdn, jdnToGregorian, jdnToJulian, gregorianToJulian, julianToGregorian, getDaysInMonth, - HistDate, YearDate, CalDate, + HistDate, YearDate, CalDate, HistEvent, queryServer, jsonToHistDate, jsonToHistEvent, - DAY_SCALE, MONTH_SCALE, stepDate, inDateScale, getScaleRatio, getUnitDiff, + DAY_SCALE, MONTH_SCALE, stepDate, inDateScale, getScaleRatio, getUnitDiff, getEventPrecision, dateToUnit, DateRangeTree, } from '/src/lib.ts' @@ -142,6 +142,21 @@ test('getUnitDiff', () => { expect(getUnitDiff(new CalDate(-1, 1, 10), (new CalDate(10, 11, 2)), 1)).toBe(10) expect(getUnitDiff(new YearDate(-5000), (new YearDate(-6500)), 10)).toBe(150) }) +test('getEventPrecision', () => { + expect(getEventPrecision(new HistEvent(1, 'one', new YearDate(-5000), new YearDate(-4991)))).toBe(10) + expect(getEventPrecision(new HistEvent(1, 'one', new YearDate(-5000), new YearDate(-4990)))).toBe(100) + expect(getEventPrecision(new HistEvent(1, 'one', new CalDate(2000, 1, 1), new CalDate(2150, 1, 1)))).toBe(1000) + expect(getEventPrecision(new HistEvent(1, 'one', new CalDate(1, 2, 3), new CalDate(1, 2, 25)))).toBe(MONTH_SCALE) + expect(getEventPrecision(new HistEvent(1, 'one', new CalDate(1, 2, 3), new CalDate(1, 2, 3)))).toBe(DAY_SCALE) +}) +test('dateToUnit', () => { + expect(dateToUnit(new CalDate(2013), 1e3)).toBe(2) + expect(dateToUnit(new CalDate(2013), 100)).toBe(20) + expect(dateToUnit(new CalDate(2013), 1)).toBe(2013) + expect(dateToUnit(new YearDate(-5123), 10)).toBe(-513) + expect(dateToUnit(new CalDate(1911, 12, 3), MONTH_SCALE)).toBe(gregorianToJdn(1911, 12, 1)) + expect(dateToUnit(new CalDate(1911, 12, 3, false), DAY_SCALE)).toBe(julianToJdn(1911, 12, 3)) +}) test('DateRangeTree', () => { let ranges = new DateRangeTree() -- cgit v1.2.3