Fixed location timeline
This commit is contained in:
1 parent
56d8818581
commit
270652f1a8
3 files changed
+59
-9
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { combineLocationOwnerMarkers } from '../src/birdTimeline.ts';
|
||||
|
||||
const location = { id: 'location', eventType: 'location_updated', eventDate: '2023-04-07', createdAt: '2026-10-07T12:00:00Z', locationLabel: 'Warwick, RI, US', toWorkspaceId: 1 };
|
||||
const owner = { ...location, id: 'owner', eventType: 'owner_changed' };
|
||||
const normalize = (value: string) => value.replace('United States', 'US');
|
||||
|
||||
test('combines a same-date location and owner change without modifying saved events', () => {
|
||||
const events = [location, { ...owner, locationLabel: 'Warwick, RI, United States' }];
|
||||
assert.deepEqual(combineLocationOwnerMarkers(events, normalize).map(event => event.id), ['owner']);
|
||||
assert.equal(events.length, 2);
|
||||
});
|
||||
|
||||
test('preserves different dates, locations, flocks, and standalone location changes', () => {
|
||||
for (const other of [
|
||||
{ ...owner, eventDate: '2023-04-08' },
|
||||
{ ...owner, locationLabel: 'Providence, RI, US' },
|
||||
{ ...owner, toWorkspaceId: 2 },
|
||||
{ ...owner, locationLabel: null },
|
||||
]) assert.equal(combineLocationOwnerMarkers([location, other], normalize).length, 2);
|
||||
assert.deepEqual(combineLocationOwnerMarkers([location], normalize), [location]);
|
||||
});
|
||||
Reference in new issue
Block a user