-
Notifications
You must be signed in to change notification settings - Fork 518
Expand file tree
/
Copy pathmessage-block.completion.test.tsx
More file actions
72 lines (64 loc) · 1.75 KB
/
message-block.completion.test.tsx
File metadata and controls
72 lines (64 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react'
import { describe, test, expect } from 'bun:test'
import { renderToStaticMarkup } from 'react-dom/server'
import { MessageBlock } from '../message-block'
import '../../state/theme-store' // Initialize theme store
import { chatThemes, createMarkdownPalette } from '../../utils/theme-system'
const theme = chatThemes.dark
const markdownPalette = createMarkdownPalette(theme)
const baseProps = {
messageId: 'ai-1',
blocks: undefined,
content: 'Hello there',
isUser: false,
isAi: true,
isLoading: false,
timestamp: '12:00',
isComplete: false,
completionTime: undefined,
credits: undefined,
timer: {
start: () => {},
stop: () => {},
elapsedSeconds: 0,
startTime: null,
},
textColor: theme.foreground,
timestampColor: theme.muted,
markdownOptions: {
codeBlockWidth: 72,
palette: markdownPalette,
},
availableWidth: 80,
collapsedAgents: new Set<string>(),
streamingAgents: new Set<string>(),
onToggleCollapsed: () => {},
}
describe('MessageBlock completion time', () => {
test('renders completion time and credits when complete', () => {
const markup = renderToStaticMarkup(
<MessageBlock
{...baseProps}
isComplete={true}
completionTime="7s"
credits={3}
markdownPalette={markdownPalette}
/>,
)
expect(markup).toContain('7s')
expect(markup).toContain('3 credits')
})
test('omits completion line when not complete', () => {
const markup = renderToStaticMarkup(
<MessageBlock
{...baseProps}
isComplete={false}
completionTime="7s"
credits={3}
markdownPalette={markdownPalette}
/>,
)
expect(markup).not.toContain('7s')
expect(markup).not.toContain('3 credits')
})
})