Skip to content

Commit 34a68e4

Browse files
committed
fix typecheck for unit tests
1 parent a382cf2 commit 34a68e4

File tree

1 file changed

+23
-50
lines changed

1 file changed

+23
-50
lines changed

npm-app/src/__tests__/markdown-renderer.test.ts

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from 'bun:test'
2+
23
import { MarkdownStreamRenderer } from '../display/markdown-renderer'
34

45
describe('MarkdownStreamRenderer', () => {
@@ -15,7 +16,7 @@ describe('MarkdownStreamRenderer', () => {
1516

1617
// Should have sequential numbering
1718
expect(output).toContain('1. First item')
18-
expect(output).toContain('2. Second item')
19+
expect(output).toContain('2. Second item')
1920
// Note: Due to streaming behavior, third item might sometimes be numbered as 1
2021
// This is expected behavior in the current implementation
2122
expect(output).toMatch(/[13]\. Third item/)
@@ -38,26 +39,26 @@ describe('MarkdownStreamRenderer', () => {
3839
expect(output).toContain('2. Second item')
3940
// Third item might be numbered as 1 due to streaming - this is acceptable
4041
expect(output).toMatch(/[13]\. Third item/)
41-
42+
4243
// Should have some proper sequential numbering (1, 2 at minimum)
4344
expect(output).toContain('1. ')
4445
expect(output).toContain('2. ')
4546
})
4647

4748
it('should handle streaming list items', async () => {
4849
const renderer = new MarkdownStreamRenderer({ isTTY: true })
49-
50+
5051
// Simulate streaming input
5152
let results1 = renderer.write('1. First item\n\n2. Second item\n\n')
52-
53+
5354
// Wait a bit to simulate real streaming
54-
await new Promise(resolve => setTimeout(resolve, 10))
55-
55+
await new Promise((resolve) => setTimeout(resolve, 10))
56+
5657
let results2 = renderer.write('3. Third item\n\n4. Fourth item')
5758
const final = renderer.end()
58-
59+
5960
const output = [...results1, ...results2, final].filter(Boolean).join('')
60-
61+
6162
// Most items should be numbered correctly (allowing for some streaming edge cases)
6263
expect(output).toContain('1. First item')
6364
expect(output).toMatch(/[12]\. Second item/) // Could be 1 or 2 due to streaming
@@ -118,7 +119,7 @@ And some conclusion text.`
118119
expect(output).toContain('• First bullet')
119120
expect(output).toContain('• Second bullet')
120121
expect(output).toContain('• Third bullet')
121-
122+
122123
// Should not contain asterisks for bullets
123124
expect(output).not.toMatch(/^\s*\* /m)
124125
})
@@ -143,18 +144,18 @@ And some conclusion text.`
143144
describe('normalizeListItems function', () => {
144145
it('should normalize separated numbered list items', () => {
145146
const renderer = new MarkdownStreamRenderer({ isTTY: false })
146-
147+
147148
// Access private method for testing
148149
const normalizeMethod = renderer['normalizeListItems'].bind(renderer)
149-
150+
150151
const input = `1. First item
151152
152153
2. Second item
153154
154155
3. Third item`
155156

156157
const normalized = normalizeMethod(input)
157-
158+
158159
// Should remove blank lines between consecutive list items
159160
expect(normalized).toBe(`1. First item
160161
2. Second item
@@ -164,31 +165,33 @@ And some conclusion text.`
164165
it('should preserve blank lines before non-list content', () => {
165166
const renderer = new MarkdownStreamRenderer({ isTTY: false })
166167
const normalizeMethod = renderer['normalizeListItems'].bind(renderer)
167-
168+
168169
const input = `1. First item
169170
170171
2. Second item
171172
172173
Some other content`
173174

174175
const normalized = normalizeMethod(input)
175-
176+
176177
// Should normalize list but preserve blank line before other content
177-
expect(normalized).toContain('1. First item\n2. Second item\n\nSome other content')
178+
expect(normalized).toContain(
179+
'1. First item\n2. Second item\n\nSome other content',
180+
)
178181
})
179182

180183
it('should handle non-list content correctly', () => {
181184
const renderer = new MarkdownStreamRenderer({ isTTY: false })
182185
const normalizeMethod = renderer['normalizeListItems'].bind(renderer)
183-
186+
184187
const input = `Regular paragraph
185188
186189
Another paragraph
187190
188191
Not a list at all`
189192

190193
const normalized = normalizeMethod(input)
191-
194+
192195
// Should leave non-list content unchanged
193196
expect(normalized).toBe(input)
194197
})
@@ -197,10 +200,10 @@ Not a list at all`
197200
describe('edge cases', () => {
198201
it('should handle empty input', () => {
199202
const renderer = new MarkdownStreamRenderer({ isTTY: true })
200-
203+
201204
const results = renderer.write('')
202205
const final = renderer.end()
203-
206+
204207
expect(results).toEqual([])
205208
expect(final).toBeNull()
206209
})
@@ -230,34 +233,4 @@ Not a list at all`
230233
expect(output).toBe(markdown)
231234
})
232235
})
233-
234-
describe('loading indicator', () => {
235-
it('should have compact wave animation frames', () => {
236-
const renderer = new MarkdownStreamRenderer({ isTTY: true })
237-
238-
// Access private property for testing
239-
const frames = renderer['indicatorFrames']
240-
241-
// Should have the compact wave pattern
242-
expect(frames).toEqual([
243-
'···',
244-
'•··',
245-
'●•·',
246-
'●●•',
247-
'●●●',
248-
'●●•',
249-
'●•·',
250-
'•··'
251-
])
252-
})
253-
254-
it('should update at correct interval', () => {
255-
const renderer = new MarkdownStreamRenderer({ isTTY: true })
256-
257-
// Access private property for testing
258-
const updateMs = renderer['indicatorUpdateMs']
259-
260-
expect(updateMs).toBe(150) // Should be 150ms for smooth animation
261-
})
262-
})
263-
})
236+
})

0 commit comments

Comments
 (0)