@jsb188/calendar 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,10 @@ import {
5
5
  getCalendarMonthCells,
6
6
  getCalendarTimedLayout,
7
7
  } from '../src/libs/calendar-geometry.ts';
8
- import { getCalendarRange, parseCalendarDateParam } from '../src/libs/calendar-range.ts';
8
+ import {
9
+ getCalendarRange,
10
+ parseCalendarDateParam,
11
+ } from '../src/libs/calendar-range.ts';
9
12
  import type { CalendarEventObj } from '../src/types/calendar.d.ts';
10
13
 
11
14
  const LA = 'America/Los_Angeles';
@@ -28,7 +31,12 @@ function buildWeek() {
28
31
  * Build one timed event. Times are ISO strings so the tests read as instants.
29
32
  */
30
33
 
31
- function buildEvent(id: string, startAt: string, endAt: string, overrides: Partial<CalendarEventObj> = {}): CalendarEventObj {
34
+ function buildEvent(
35
+ id: string,
36
+ startAt: string,
37
+ endAt: string,
38
+ overrides: Partial<CalendarEventObj> = {},
39
+ ): CalendarEventObj {
32
40
  return {
33
41
  id,
34
42
  calendarId: 'cal1',
@@ -38,7 +46,7 @@ function buildEvent(id: string, startAt: string, endAt: string, overrides: Parti
38
46
  allDay: false,
39
47
  kind: 'SHIFT',
40
48
  status: 'PUBLISHED',
41
- assigneeAccountIds: [],
49
+ assigneeResourceIds: [],
42
50
  ...overrides,
43
51
  };
44
52
  }
@@ -47,7 +55,10 @@ describe('getCalendarTimedLayout', () => {
47
55
  it('places one event at the right minutes of its day', () => {
48
56
  const week = buildWeek();
49
57
  // 09:00–17:00 local on Wednesday the 22nd
50
- const layout = getCalendarTimedLayout([buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-23T00:00:00Z')], week.days);
58
+ const layout = getCalendarTimedLayout(
59
+ [buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-23T00:00:00Z')],
60
+ week.days,
61
+ );
51
62
 
52
63
  expect(layout).toHaveLength(1);
53
64
  expect(layout[0].dayIndex).toBe(3);
@@ -93,12 +104,44 @@ describe('getCalendarTimedLayout', () => {
93
104
  expect(layout[0].endMinute).toBe(24 * 60);
94
105
  });
95
106
 
107
+ it('draws an event starting exactly at midnight on its own day', () => {
108
+ const week = buildWeek();
109
+ // 00:00–08:00 local on Wednesday the 22nd. The mirror of the case above:
110
+ // the day span is found by binary search, so both boundary directions
111
+ // have to land on the day the event actually belongs to.
112
+ const layout = getCalendarTimedLayout(
113
+ [buildEvent('opens', '2026-07-22T07:00:00Z', '2026-07-22T15:00:00Z')],
114
+ week.days,
115
+ );
116
+
117
+ expect(layout).toHaveLength(1);
118
+ expect(layout[0].dayIndex).toBe(3);
119
+ expect(layout[0].startMinute).toBe(0);
120
+ });
121
+
122
+ it('draws an event covering the first and last day of the range', () => {
123
+ const week = buildWeek();
124
+ // Sunday 00:00 local through the following Sunday: every column, with
125
+ // both ends of the binary search clamped to the range
126
+ const layout = getCalendarTimedLayout(
127
+ [buildEvent('all_week', '2026-07-19T07:00:00Z', '2026-07-26T07:00:00Z')],
128
+ week.days,
129
+ );
130
+
131
+ expect(layout.map((entry) => entry.dayIndex)).toEqual([
132
+ 0, 1, 2, 3, 4, 5, 6,
133
+ ]);
134
+ });
135
+
96
136
  it('splits two overlapping events down the middle', () => {
97
137
  const week = buildWeek();
98
- const layout = getCalendarTimedLayout([
99
- buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T20:00:00Z'),
100
- buildEvent('b', '2026-07-22T17:00:00Z', '2026-07-22T21:00:00Z'),
101
- ], week.days);
138
+ const layout = getCalendarTimedLayout(
139
+ [
140
+ buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T20:00:00Z'),
141
+ buildEvent('b', '2026-07-22T17:00:00Z', '2026-07-22T21:00:00Z'),
142
+ ],
143
+ week.days,
144
+ );
102
145
 
103
146
  expect(layout.map((entry) => entry.columnCount)).toEqual([2, 2]);
104
147
  expect(layout.map((entry) => entry.left).sort()).toEqual([0, 0.5]);
@@ -108,17 +151,24 @@ describe('getCalendarTimedLayout', () => {
108
151
  it('gives a non-overlapping later event the full width', () => {
109
152
  const week = buildWeek();
110
153
  // Two at 9am, one at 2pm: the 2pm event is its own cluster
111
- const layout = getCalendarTimedLayout([
112
- buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T18:00:00Z'),
113
- buildEvent('b', '2026-07-22T16:00:00Z', '2026-07-22T18:00:00Z'),
114
- buildEvent('c', '2026-07-22T21:00:00Z', '2026-07-22T22:00:00Z'),
115
- ], week.days);
154
+ const layout = getCalendarTimedLayout(
155
+ [
156
+ buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T18:00:00Z'),
157
+ buildEvent('b', '2026-07-22T16:00:00Z', '2026-07-22T18:00:00Z'),
158
+ buildEvent('c', '2026-07-22T21:00:00Z', '2026-07-22T22:00:00Z'),
159
+ ],
160
+ week.days,
161
+ );
116
162
 
117
163
  const afternoon = layout.find((entry) => entry.event.id === 'c');
118
164
 
119
165
  expect(afternoon?.columnCount).toBe(1);
120
166
  expect(afternoon?.width).toBe(1);
121
- expect(layout.filter((entry) => entry.event.id !== 'c').every((entry) => entry.columnCount === 2)).toBe(true);
167
+ expect(
168
+ layout
169
+ .filter((entry) => entry.event.id !== 'c')
170
+ .every((entry) => entry.columnCount === 2),
171
+ ).toBe(true);
122
172
  });
123
173
 
124
174
  it('treats a transitively-overlapping chain as one cluster', () => {
@@ -126,11 +176,14 @@ describe('getCalendarTimedLayout', () => {
126
176
  // A 9-12, B 10-13, C 11-14 — A and C never touch, but every column is
127
177
  // still busy when C starts, so all three must share the width or B
128
178
  // would be drawn over one of them
129
- const layout = getCalendarTimedLayout([
130
- buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T19:00:00Z'),
131
- buildEvent('b', '2026-07-22T17:00:00Z', '2026-07-22T20:00:00Z'),
132
- buildEvent('c', '2026-07-22T18:00:00Z', '2026-07-22T21:00:00Z'),
133
- ], week.days);
179
+ const layout = getCalendarTimedLayout(
180
+ [
181
+ buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T19:00:00Z'),
182
+ buildEvent('b', '2026-07-22T17:00:00Z', '2026-07-22T20:00:00Z'),
183
+ buildEvent('c', '2026-07-22T18:00:00Z', '2026-07-22T21:00:00Z'),
184
+ ],
185
+ week.days,
186
+ );
134
187
 
135
188
  expect(layout.map((entry) => entry.columnCount)).toEqual([3, 3, 3]);
136
189
  expect(layout.map((entry) => entry.column).sort()).toEqual([0, 1, 2]);
@@ -141,13 +194,18 @@ describe('getCalendarTimedLayout', () => {
141
194
  // A 9-11, B 10-12, C 11:30-13 — the same chain shape, but C can reuse
142
195
  // the column A vacated, so two columns is the correct answer and three
143
196
  // would waste half the day's width
144
- const layout = getCalendarTimedLayout([
145
- buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T18:00:00Z'),
146
- buildEvent('b', '2026-07-22T17:00:00Z', '2026-07-22T19:00:00Z'),
147
- buildEvent('c', '2026-07-22T18:30:00Z', '2026-07-22T20:00:00Z'),
148
- ], week.days);
197
+ const layout = getCalendarTimedLayout(
198
+ [
199
+ buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T18:00:00Z'),
200
+ buildEvent('b', '2026-07-22T17:00:00Z', '2026-07-22T19:00:00Z'),
201
+ buildEvent('c', '2026-07-22T18:30:00Z', '2026-07-22T20:00:00Z'),
202
+ ],
203
+ week.days,
204
+ );
149
205
 
150
- const byId = Object.fromEntries(layout.map((entry) => [entry.event.id, entry]));
206
+ const byId = Object.fromEntries(
207
+ layout.map((entry) => [entry.event.id, entry]),
208
+ );
151
209
 
152
210
  expect(layout.map((entry) => entry.columnCount)).toEqual([2, 2, 2]);
153
211
  expect(byId.c.column).toBe(byId.a.column);
@@ -157,13 +215,18 @@ describe('getCalendarTimedLayout', () => {
157
215
  it('reuses a freed column for a later non-overlapping event in the same cluster', () => {
158
216
  const week = buildWeek();
159
217
  // A 9-10, B 9-12, C 10:30-11 — C can take A's column
160
- const layout = getCalendarTimedLayout([
161
- buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T17:00:00Z'),
162
- buildEvent('b', '2026-07-22T16:00:00Z', '2026-07-22T19:00:00Z'),
163
- buildEvent('c', '2026-07-22T17:30:00Z', '2026-07-22T18:00:00Z'),
164
- ], week.days);
218
+ const layout = getCalendarTimedLayout(
219
+ [
220
+ buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T17:00:00Z'),
221
+ buildEvent('b', '2026-07-22T16:00:00Z', '2026-07-22T19:00:00Z'),
222
+ buildEvent('c', '2026-07-22T17:30:00Z', '2026-07-22T18:00:00Z'),
223
+ ],
224
+ week.days,
225
+ );
165
226
 
166
- const byId = Object.fromEntries(layout.map((entry) => [entry.event.id, entry]));
227
+ const byId = Object.fromEntries(
228
+ layout.map((entry) => [entry.event.id, entry]),
229
+ );
167
230
 
168
231
  expect(byId.c.column).toBe(byId.a.column);
169
232
  expect(byId.b.columnCount).toBe(2);
@@ -171,9 +234,9 @@ describe('getCalendarTimedLayout', () => {
171
234
 
172
235
  it('stacks rather than slivers past the column cap', () => {
173
236
  const week = buildWeek();
174
- const events = Array.from({ length: 8 }, (_unused, index) => (
175
- buildEvent(`e${index}`, '2026-07-22T16:00:00Z', '2026-07-22T20:00:00Z')
176
- ));
237
+ const events = Array.from({ length: 8 }, (_unused, index) =>
238
+ buildEvent(`e${index}`, '2026-07-22T16:00:00Z', '2026-07-22T20:00:00Z'),
239
+ );
177
240
  const layout = getCalendarTimedLayout(events, week.days);
178
241
 
179
242
  expect(layout.every((entry) => entry.columnCount === 8)).toBe(true);
@@ -186,26 +249,37 @@ describe('getCalendarTimedLayout', () => {
186
249
  const week = buildWeek();
187
250
  // Five minutes apart and five minutes long: they do not overlap in time,
188
251
  // but both are drawn at the minimum height, so they overlap on screen
189
- const layout = getCalendarTimedLayout([
190
- buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T16:05:00Z'),
191
- buildEvent('b', '2026-07-22T16:05:00Z', '2026-07-22T16:10:00Z'),
192
- ], week.days);
252
+ const layout = getCalendarTimedLayout(
253
+ [
254
+ buildEvent('a', '2026-07-22T16:00:00Z', '2026-07-22T16:05:00Z'),
255
+ buildEvent('b', '2026-07-22T16:05:00Z', '2026-07-22T16:10:00Z'),
256
+ ],
257
+ week.days,
258
+ );
193
259
 
194
260
  expect(layout.map((entry) => entry.columnCount)).toEqual([2, 2]);
195
261
  });
196
262
 
197
263
  it('excludes all-day entries from the time grid', () => {
198
264
  const week = buildWeek();
199
- const layout = getCalendarTimedLayout([
200
- buildEvent('holiday', '2026-07-22T07:00:00Z', '2026-07-23T07:00:00Z', { allDay: true }),
201
- ], week.days);
265
+ const layout = getCalendarTimedLayout(
266
+ [
267
+ buildEvent('holiday', '2026-07-22T07:00:00Z', '2026-07-23T07:00:00Z', {
268
+ allDay: true,
269
+ }),
270
+ ],
271
+ week.days,
272
+ );
202
273
 
203
274
  expect(layout).toHaveLength(0);
204
275
  });
205
276
 
206
277
  it('drops an event entirely outside the range', () => {
207
278
  const week = buildWeek();
208
- const layout = getCalendarTimedLayout([buildEvent('past', '2026-06-01T16:00:00Z', '2026-06-01T18:00:00Z')], week.days);
279
+ const layout = getCalendarTimedLayout(
280
+ [buildEvent('past', '2026-06-01T16:00:00Z', '2026-06-01T18:00:00Z')],
281
+ week.days,
282
+ );
209
283
 
210
284
  expect(layout).toHaveLength(0);
211
285
  });
@@ -218,7 +292,10 @@ describe('getCalendarTimedLayout', () => {
218
292
  timeZone: LA,
219
293
  });
220
294
  // 9am local on the 25-hour day is 17:00Z (PST, after the transition)
221
- const layout = getCalendarTimedLayout([buildEvent('a', '2026-11-01T17:00:00Z', '2026-11-01T18:00:00Z')], range.days);
295
+ const layout = getCalendarTimedLayout(
296
+ [buildEvent('a', '2026-11-01T17:00:00Z', '2026-11-01T18:00:00Z')],
297
+ range.days,
298
+ );
222
299
 
223
300
  // Measured from the day's own start, an extra hour has already elapsed
224
301
  expect(layout[0].startMinute).toBe(10 * 60);
@@ -229,9 +306,14 @@ describe('getCalendarTimedLayout', () => {
229
306
  describe('getCalendarAllDayLayout', () => {
230
307
  it('spans an all-day entry across its day columns', () => {
231
308
  const week = buildWeek();
232
- const bars = getCalendarAllDayLayout([
233
- buildEvent('conf', '2026-07-21T07:00:00Z', '2026-07-24T07:00:00Z', { allDay: true }),
234
- ], week.days);
309
+ const bars = getCalendarAllDayLayout(
310
+ [
311
+ buildEvent('conf', '2026-07-21T07:00:00Z', '2026-07-24T07:00:00Z', {
312
+ allDay: true,
313
+ }),
314
+ ],
315
+ week.days,
316
+ );
235
317
 
236
318
  expect(bars).toHaveLength(1);
237
319
  expect(bars[0].startDayIndex).toBe(2);
@@ -241,48 +323,73 @@ describe('getCalendarAllDayLayout', () => {
241
323
 
242
324
  it('packs non-overlapping bars onto the same row', () => {
243
325
  const week = buildWeek();
244
- const bars = getCalendarAllDayLayout([
245
- buildEvent('a', '2026-07-19T07:00:00Z', '2026-07-21T07:00:00Z', { allDay: true }),
246
- buildEvent('b', '2026-07-23T07:00:00Z', '2026-07-25T07:00:00Z', { allDay: true }),
247
- ], week.days);
326
+ const bars = getCalendarAllDayLayout(
327
+ [
328
+ buildEvent('a', '2026-07-19T07:00:00Z', '2026-07-21T07:00:00Z', {
329
+ allDay: true,
330
+ }),
331
+ buildEvent('b', '2026-07-23T07:00:00Z', '2026-07-25T07:00:00Z', {
332
+ allDay: true,
333
+ }),
334
+ ],
335
+ week.days,
336
+ );
248
337
 
249
338
  expect(bars.map((bar) => bar.row)).toEqual([0, 0]);
250
339
  });
251
340
 
252
341
  it('pushes an overlapping bar to the next row', () => {
253
342
  const week = buildWeek();
254
- const bars = getCalendarAllDayLayout([
255
- buildEvent('a', '2026-07-19T07:00:00Z', '2026-07-23T07:00:00Z', { allDay: true }),
256
- buildEvent('b', '2026-07-21T07:00:00Z', '2026-07-25T07:00:00Z', { allDay: true }),
257
- ], week.days);
343
+ const bars = getCalendarAllDayLayout(
344
+ [
345
+ buildEvent('a', '2026-07-19T07:00:00Z', '2026-07-23T07:00:00Z', {
346
+ allDay: true,
347
+ }),
348
+ buildEvent('b', '2026-07-21T07:00:00Z', '2026-07-25T07:00:00Z', {
349
+ allDay: true,
350
+ }),
351
+ ],
352
+ week.days,
353
+ );
258
354
 
259
355
  expect(bars.map((bar) => bar.row).sort()).toEqual([0, 1]);
260
356
  });
261
357
 
262
- it('promotes a multi-day timed entry into the band', () => {
358
+ it('keeps a multi-day timed entry out of the all-day band', () => {
263
359
  const week = buildWeek();
264
- // A three-day closure is not usefully drawn as three tall columns
265
- const bars = getCalendarAllDayLayout([
266
- buildEvent('closure', '2026-07-20T18:00:00Z', '2026-07-23T02:00:00Z', { kind: 'BLOCK' }),
267
- ], week.days);
360
+ // Each timed segment belongs only to the timed grid.
361
+ const bars = getCalendarAllDayLayout(
362
+ [
363
+ buildEvent('closure', '2026-07-20T18:00:00Z', '2026-07-23T02:00:00Z', {
364
+ kind: 'BLOCK',
365
+ }),
366
+ ],
367
+ week.days,
368
+ );
268
369
 
269
- expect(bars).toHaveLength(1);
270
- expect(bars[0].startDayIndex).toBe(1);
271
- expect(bars[0].endDayIndex).toBe(3);
370
+ expect(bars).toHaveLength(0);
272
371
  });
273
372
 
274
373
  it('leaves a single-day timed entry in the grid', () => {
275
374
  const week = buildWeek();
276
- const bars = getCalendarAllDayLayout([buildEvent('shift', '2026-07-22T16:00:00Z', '2026-07-22T20:00:00Z')], week.days);
375
+ const bars = getCalendarAllDayLayout(
376
+ [buildEvent('shift', '2026-07-22T16:00:00Z', '2026-07-22T20:00:00Z')],
377
+ week.days,
378
+ );
277
379
 
278
380
  expect(bars).toHaveLength(0);
279
381
  });
280
382
 
281
383
  it('clips a bar that starts before or ends after the range', () => {
282
384
  const week = buildWeek();
283
- const bars = getCalendarAllDayLayout([
284
- buildEvent('long', '2026-07-01T07:00:00Z', '2026-08-01T07:00:00Z', { allDay: true }),
285
- ], week.days);
385
+ const bars = getCalendarAllDayLayout(
386
+ [
387
+ buildEvent('long', '2026-07-01T07:00:00Z', '2026-08-01T07:00:00Z', {
388
+ allDay: true,
389
+ }),
390
+ ],
391
+ week.days,
392
+ );
286
393
 
287
394
  expect(bars[0].startDayIndex).toBe(0);
288
395
  expect(bars[0].endDayIndex).toBe(6);
@@ -294,26 +401,46 @@ describe('getCalendarAllDayLayout', () => {
294
401
  describe('getCalendarEventsByDateKey', () => {
295
402
  it('lists a multi-day entry under every day it covers', () => {
296
403
  const week = buildWeek();
297
- const byDateKey = getCalendarEventsByDateKey([
298
- buildEvent('conf', '2026-07-21T07:00:00Z', '2026-07-24T07:00:00Z', { allDay: true }),
299
- ], week.days);
404
+ const byDateKey = getCalendarEventsByDateKey(
405
+ [
406
+ buildEvent('conf', '2026-07-21T07:00:00Z', '2026-07-24T07:00:00Z', {
407
+ allDay: true,
408
+ }),
409
+ ],
410
+ week.days,
411
+ );
300
412
 
301
413
  expect(byDateKey.get('2026-07-20')?.map((event) => event.id)).toEqual([]);
302
- expect(byDateKey.get('2026-07-21')?.map((event) => event.id)).toEqual(['conf']);
303
- expect(byDateKey.get('2026-07-22')?.map((event) => event.id)).toEqual(['conf']);
304
- expect(byDateKey.get('2026-07-23')?.map((event) => event.id)).toEqual(['conf']);
414
+ expect(byDateKey.get('2026-07-21')?.map((event) => event.id)).toEqual([
415
+ 'conf',
416
+ ]);
417
+ expect(byDateKey.get('2026-07-22')?.map((event) => event.id)).toEqual([
418
+ 'conf',
419
+ ]);
420
+ expect(byDateKey.get('2026-07-23')?.map((event) => event.id)).toEqual([
421
+ 'conf',
422
+ ]);
305
423
  expect(byDateKey.get('2026-07-24')?.map((event) => event.id)).toEqual([]);
306
424
  });
307
425
 
308
426
  it('sorts all-day entries above timed ones, then chronologically', () => {
309
427
  const week = buildWeek();
310
- const byDateKey = getCalendarEventsByDateKey([
311
- buildEvent('late', '2026-07-22T21:00:00Z', '2026-07-22T22:00:00Z'),
312
- buildEvent('early', '2026-07-22T16:00:00Z', '2026-07-22T17:00:00Z'),
313
- buildEvent('holiday', '2026-07-22T07:00:00Z', '2026-07-23T07:00:00Z', { allDay: true }),
314
- ], week.days);
428
+ const byDateKey = getCalendarEventsByDateKey(
429
+ [
430
+ buildEvent('late', '2026-07-22T21:00:00Z', '2026-07-22T22:00:00Z'),
431
+ buildEvent('early', '2026-07-22T16:00:00Z', '2026-07-22T17:00:00Z'),
432
+ buildEvent('holiday', '2026-07-22T07:00:00Z', '2026-07-23T07:00:00Z', {
433
+ allDay: true,
434
+ }),
435
+ ],
436
+ week.days,
437
+ );
315
438
 
316
- expect(byDateKey.get('2026-07-22')?.map((event) => event.id)).toEqual(['holiday', 'early', 'late']);
439
+ expect(byDateKey.get('2026-07-22')?.map((event) => event.id)).toEqual([
440
+ 'holiday',
441
+ 'early',
442
+ 'late',
443
+ ]);
317
444
  });
318
445
 
319
446
  it('gives every day in the range a bucket, empty or not', () => {
@@ -321,7 +448,9 @@ describe('getCalendarEventsByDateKey', () => {
321
448
  const byDateKey = getCalendarEventsByDateKey([], week.days);
322
449
 
323
450
  expect(byDateKey.size).toBe(7);
324
- expect([...byDateKey.values()].every((events) => events.length === 0)).toBe(true);
451
+ expect([...byDateKey.values()].every((events) => events.length === 0)).toBe(
452
+ true,
453
+ );
325
454
  });
326
455
  });
327
456
 
@@ -336,7 +465,11 @@ describe('getCalendarMonthCells', () => {
336
465
  const cells = getCalendarMonthCells([], month.days, 3);
337
466
 
338
467
  expect(cells).toHaveLength(42);
339
- expect(cells.every((cell) => cell.events.length === 0 && cell.overflowCount === 0)).toBe(true);
468
+ expect(
469
+ cells.every(
470
+ (cell) => cell.events.length === 0 && cell.overflowCount === 0,
471
+ ),
472
+ ).toBe(true);
340
473
  });
341
474
 
342
475
  it('truncates a busy cell and reports the remainder', () => {
@@ -347,9 +480,16 @@ describe('getCalendarMonthCells', () => {
347
480
  timeZone: LA,
348
481
  });
349
482
  const events = Array.from({ length: 7 }, (_unused, index) =>
350
- buildEvent(`e${index}`, `2026-07-22T${String(16 + index).padStart(2, '0')}:00:00Z`, `2026-07-22T${String(17 + index).padStart(2, '0')}:00:00Z`));
483
+ buildEvent(
484
+ `e${index}`,
485
+ `2026-07-22T${String(16 + index).padStart(2, '0')}:00:00Z`,
486
+ `2026-07-22T${String(17 + index).padStart(2, '0')}:00:00Z`,
487
+ ),
488
+ );
351
489
 
352
- const cell = getCalendarMonthCells(events, month.days, 3).find((entry) => entry.day.dateKey === '2026-07-22');
490
+ const cell = getCalendarMonthCells(events, month.days, 3).find(
491
+ (entry) => entry.day.dateKey === '2026-07-22',
492
+ );
353
493
 
354
494
  // The count is computed, never left to a CSS overflow to hide
355
495
  expect(cell?.events).toHaveLength(3);
@@ -364,12 +504,18 @@ describe('getCalendarMonthCells', () => {
364
504
  timeZone: LA,
365
505
  });
366
506
  const cells = getCalendarMonthCells(
367
- [buildEvent('conf', '2026-07-21T07:00:00Z', '2026-07-24T07:00:00Z', { allDay: true })],
507
+ [
508
+ buildEvent('conf', '2026-07-21T07:00:00Z', '2026-07-24T07:00:00Z', {
509
+ allDay: true,
510
+ }),
511
+ ],
368
512
  month.days,
369
513
  3,
370
514
  );
371
515
 
372
- const covered = cells.filter((cell) => cell.events.length > 0).map((cell) => cell.day.dateKey);
516
+ const covered = cells
517
+ .filter((cell) => cell.events.length > 0)
518
+ .map((cell) => cell.day.dateKey);
373
519
 
374
520
  expect(covered).toEqual(['2026-07-21', '2026-07-22', '2026-07-23']);
375
521
  });
@@ -5,7 +5,10 @@ import {
5
5
  getCalendarPointerSlot,
6
6
  getCalendarResizeRange,
7
7
  } from '../src/libs/calendar-gesture.ts';
8
- import { getCalendarRange, parseCalendarDateParam } from '../src/libs/calendar-range.ts';
8
+ import {
9
+ getCalendarRange,
10
+ parseCalendarDateParam,
11
+ } from '../src/libs/calendar-range.ts';
9
12
 
10
13
  const LA = 'America/Los_Angeles';
11
14
  const NOW = new Date('2026-07-22T19:00:00Z');
@@ -65,10 +68,24 @@ describe('getCalendarPointerSlot', () => {
65
68
  it('clamps a pointer dragged outside the grid', () => {
66
69
  const week = buildWeek();
67
70
 
68
- expect(getCalendarPointerSlot({ offsetX: -50, offsetY: -100, contentWidth: 700, hourHeight: 48, days: week.days }))
69
- .toEqual({ dayIndex: 0, minute: 0 });
70
- expect(getCalendarPointerSlot({ offsetX: 9999, offsetY: 99999, contentWidth: 700, hourHeight: 48, days: week.days }))
71
- .toEqual({ dayIndex: 6, minute: 24 * 60 });
71
+ expect(
72
+ getCalendarPointerSlot({
73
+ offsetX: -50,
74
+ offsetY: -100,
75
+ contentWidth: 700,
76
+ hourHeight: 48,
77
+ days: week.days,
78
+ }),
79
+ ).toEqual({ dayIndex: 0, minute: 0 });
80
+ expect(
81
+ getCalendarPointerSlot({
82
+ offsetX: 9999,
83
+ offsetY: 99999,
84
+ contentWidth: 700,
85
+ hourHeight: 48,
86
+ days: week.days,
87
+ }),
88
+ ).toEqual({ dayIndex: 6, minute: 24 * 60 });
72
89
  });
73
90
  });
74
91
 
@@ -100,7 +117,9 @@ describe('getCalendarCreateRange', () => {
100
117
  moved: true,
101
118
  });
102
119
 
103
- expect(range.endAt.getTime() - range.startAt.getTime()).toBe(3 * 60 * 60_000);
120
+ expect(range.endAt.getTime() - range.startAt.getTime()).toBe(
121
+ 3 * 60 * 60_000,
122
+ );
104
123
  });
105
124
 
106
125
  it('accepts a drag drawn upward', () => {
@@ -115,7 +134,9 @@ describe('getCalendarCreateRange', () => {
115
134
  });
116
135
 
117
136
  expect(range.startAt.toISOString()).toBe('2026-07-22T16:00:00.000Z');
118
- expect(range.endAt.getTime() - range.startAt.getTime()).toBe(3 * 60 * 60_000);
137
+ expect(range.endAt.getTime() - range.startAt.getTime()).toBe(
138
+ 3 * 60 * 60_000,
139
+ );
119
140
  });
120
141
 
121
142
  it('gives a barely-moved drag the minimum length', () => {
@@ -159,7 +180,9 @@ describe('getCalendarCreateRange', () => {
159
180
  moved: false,
160
181
  });
161
182
 
162
- expect(range.endAt.getTime()).toBeLessThanOrEqual(week.days[3].endAt.getTime());
183
+ expect(range.endAt.getTime()).toBeLessThanOrEqual(
184
+ week.days[3].endAt.getTime(),
185
+ );
163
186
  });
164
187
  });
165
188
 
@@ -181,7 +204,9 @@ describe('getCalendarMoveRange', () => {
181
204
 
182
205
  // The block starts an hour before the pointer, not at it
183
206
  expect(range.startAt.toISOString()).toBe('2026-07-22T20:00:00.000Z');
184
- expect(range.endAt.getTime() - range.startAt.getTime()).toBe(4 * 60 * 60_000);
207
+ expect(range.endAt.getTime() - range.startAt.getTime()).toBe(
208
+ 4 * 60 * 60_000,
209
+ );
185
210
  });
186
211
 
187
212
  it('moves an event to another day', () => {
@@ -211,8 +236,12 @@ describe('getCalendarMoveRange', () => {
211
236
  currentMinute: 23 * 60,
212
237
  });
213
238
 
214
- expect(range.endAt.getTime()).toBeLessThanOrEqual(week.days[3].endAt.getTime());
215
- expect(range.endAt.getTime() - range.startAt.getTime()).toBe(4 * 60 * 60_000);
239
+ expect(range.endAt.getTime()).toBeLessThanOrEqual(
240
+ week.days[3].endAt.getTime(),
241
+ );
242
+ expect(range.endAt.getTime() - range.startAt.getTime()).toBe(
243
+ 4 * 60 * 60_000,
244
+ );
216
245
  });
217
246
 
218
247
  it('keeps a shift the same number of hours across a DST day', () => {
@@ -230,7 +259,9 @@ describe('getCalendarMoveRange', () => {
230
259
  });
231
260
 
232
261
  // Four hours of actual work stays four hours, even on a 25-hour day
233
- expect(range.endAt.getTime() - range.startAt.getTime()).toBe(4 * 60 * 60_000);
262
+ expect(range.endAt.getTime() - range.startAt.getTime()).toBe(
263
+ 4 * 60 * 60_000,
264
+ );
234
265
  });
235
266
  });
236
267