Skip to content

Commit 4e0b7be

Browse files
committed
fix the test
1 parent c4ee38d commit 4e0b7be

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

webview-ui/src/__mocks__/shiki.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ export type BundledLanguage = string
1515
export type Highlighter = any
1616
export type ShikiTransformer = any
1717

18-
export const createHighlighter = jest.fn(() => Promise.resolve({
19-
codeToHtml: jest.fn((code: string) => `<pre><code>${code}</code></pre>`),
20-
getLoadedThemes: jest.fn(() => []),
21-
loadTheme: jest.fn(),
22-
}))
18+
export const createHighlighter = jest.fn(() =>
19+
Promise.resolve({
20+
codeToHtml: jest.fn((code: string) => `<pre><code>${code}</code></pre>`),
21+
getLoadedThemes: jest.fn(() => []),
22+
loadTheme: jest.fn(),
23+
}),
24+
)
2325

2426
export const codeToHast = jest.fn()
2527
export const codeToHtml = jest.fn((code: string) => `<pre><code>${code}</code></pre>`)
2628
export const codeToTokens = jest.fn()
2729
export const codeToTokensBase = jest.fn()
2830
export const codeToTokensWithThemes = jest.fn()
2931
export const getLastGrammarState = jest.fn()
30-
export const getSingletonHighlighter = jest.fn()
32+
export const getSingletonHighlighter = jest.fn()

webview-ui/src/components/chat/__tests__/BatchFilePermission.test.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ describe("BatchFilePermission", () => {
100100
// Find the header that contains our file path and click it
101101
const filePathElement = screen.getByText(/Button\.tsx.*export const Button/)
102102
// The ToolUseBlockHeader is the parent div with the flex class
103-
const headerElement = filePathElement.closest('.flex.items-center.select-none')
104-
103+
const headerElement = filePathElement.closest(".flex.items-center.select-none")
104+
105105
if (headerElement) {
106106
fireEvent.click(headerElement)
107107
}
@@ -140,11 +140,7 @@ describe("BatchFilePermission", () => {
140140
it("re-renders when timestamp changes", () => {
141141
const { rerender } = render(
142142
<TranslationProvider>
143-
<BatchFilePermission
144-
files={mockFiles}
145-
onPermissionResponse={mockOnPermissionResponse}
146-
ts={1000}
147-
/>
143+
<BatchFilePermission files={mockFiles} onPermissionResponse={mockOnPermissionResponse} ts={1000} />
148144
</TranslationProvider>,
149145
)
150146

@@ -154,11 +150,7 @@ describe("BatchFilePermission", () => {
154150
// Re-render with new timestamp
155151
rerender(
156152
<TranslationProvider>
157-
<BatchFilePermission
158-
files={mockFiles}
159-
onPermissionResponse={mockOnPermissionResponse}
160-
ts={2000}
161-
/>
153+
<BatchFilePermission files={mockFiles} onPermissionResponse={mockOnPermissionResponse} ts={2000} />
162154
</TranslationProvider>,
163155
)
164156

@@ -178,8 +170,8 @@ describe("BatchFilePermission", () => {
178170
)
179171

180172
// All files should have external link icons
181-
const externalLinkIcons = screen.getAllByText((content, element) => {
182-
return element?.classList?.contains('codicon-link-external') ?? false
173+
const externalLinkIcons = screen.getAllByText((_content, element) => {
174+
return element?.classList?.contains("codicon-link-external") ?? false
183175
})
184176
expect(externalLinkIcons).toHaveLength(mockFiles.length)
185177
})

0 commit comments

Comments
 (0)