Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { groupChatTimeline, type ChatBoundaryEntry, type ChatMessageEntry } from '../../src/lib/ui/chat-timeline.js';
|
||||
import {
|
||||
groupChatTimeline,
|
||||
type ChatBoundaryEntry,
|
||||
type ChatMessageEntry
|
||||
} from '../../src/lib/ui/chat-timeline.js';
|
||||
|
||||
const boundary = (event: ChatBoundaryEntry['event'], time: string | null): ChatBoundaryEntry => ({
|
||||
type: 'boundary', event, time, context: { realTime: null, matchElapsedMs: null, round: null }
|
||||
type: 'boundary',
|
||||
event,
|
||||
time,
|
||||
context: { realTime: null, matchElapsedMs: null, round: null }
|
||||
});
|
||||
|
||||
const message = (text: string, round: number | null = 7): ChatMessageEntry => ({
|
||||
@@ -14,8 +21,11 @@ const message = (text: string, round: number | null = 7): ChatMessageEntry => ({
|
||||
describe('chat timeline display groups', () => {
|
||||
it('retains every lifecycle event in log order, including repeated starts, resets and unknown times', () => {
|
||||
const entries = Object.freeze([
|
||||
boundary('end', '80:00'), boundary('start', null), boundary('start', '0:00'),
|
||||
boundary('reset', '0:00'), boundary('end', null)
|
||||
boundary('end', '80:00'),
|
||||
boundary('start', null),
|
||||
boundary('start', '0:00'),
|
||||
boundary('reset', '0:00'),
|
||||
boundary('end', null)
|
||||
]);
|
||||
const timeline = groupChatTimeline(entries);
|
||||
|
||||
@@ -41,10 +51,14 @@ describe('chat timeline display groups', () => {
|
||||
});
|
||||
|
||||
it('preserves consecutive and repeated messages with their individual contexts', () => {
|
||||
const entries = Object.freeze([message('hello', 7), message('hello', 8), message('later', null)]);
|
||||
const entries = Object.freeze([
|
||||
message('hello', 7),
|
||||
message('hello', 8),
|
||||
message('later', null)
|
||||
]);
|
||||
const timeline = groupChatTimeline(entries);
|
||||
|
||||
expect(timeline).toEqual(entries.map(entry => ({ type: 'message', entry })));
|
||||
expect(timeline).toEqual(entries.map((entry) => ({ type: 'message', entry })));
|
||||
timeline.forEach((item, index) => {
|
||||
if (item.type !== 'message') throw new Error('Expected message');
|
||||
expect(item.entry).toBe(entries[index]);
|
||||
|
||||
Reference in New Issue
Block a user