Skip to content

Commit d892b14

Browse files
committed
Misc fixes
1 parent 1102f18 commit d892b14

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

packages/streamdown/__tests__/mermaid-utils.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ describe("svgToPngBlob", () => {
3939
};
4040

4141
originalImage = globalThis.Image;
42-
globalThis.Image = (() => mockImage) as any;
42+
globalThis.Image = class {
43+
constructor() {
44+
// biome-ignore lint/correctness/noConstructorReturn: need constructor mock to return shared mockImage
45+
return mockImage;
46+
}
47+
} as any;
4348
});
4449

4550
afterEach(() => {

packages/streamdown/__tests__/table-dropdowns.test.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,14 @@ describe("TableCopyDropdown", () => {
260260
});
261261
// Mock ClipboardItem if not present
262262
if (!globalThis.ClipboardItem) {
263-
globalThis.ClipboardItem = ((data: Record<string, Blob>) => ({
264-
types: Object.keys(data),
265-
data,
266-
})) as any;
263+
globalThis.ClipboardItem = class {
264+
types: string[];
265+
data: Record<string, Blob>;
266+
constructor(data: Record<string, Blob>) {
267+
this.types = Object.keys(data);
268+
this.data = data;
269+
}
270+
} as any;
267271
}
268272
});
269273

@@ -297,7 +301,8 @@ describe("TableCopyDropdown", () => {
297301
);
298302
expect(mdBtn).toBeTruthy();
299303

300-
await act(() => {
304+
// biome-ignore lint/suspicious/useAwait: act needs async to flush clipboard promises
305+
await act(async () => {
301306
// biome-ignore lint/style/noNonNullAssertion: test assertion
302307
fireEvent.click(mdBtn!);
303308
});
@@ -317,7 +322,8 @@ describe("TableCopyDropdown", () => {
317322
fireEvent.click(toggleBtn!);
318323

319324
const csvBtn = container.querySelector('button[title="Copy table as CSV"]');
320-
await act(() => {
325+
// biome-ignore lint/suspicious/useAwait: act needs async to flush clipboard promises
326+
await act(async () => {
321327
// biome-ignore lint/style/noNonNullAssertion: test assertion
322328
fireEvent.click(csvBtn!);
323329
});
@@ -336,7 +342,8 @@ describe("TableCopyDropdown", () => {
336342
fireEvent.click(toggleBtn!);
337343

338344
const tsvBtn = container.querySelector('button[title="Copy table as TSV"]');
339-
await act(() => {
345+
// biome-ignore lint/suspicious/useAwait: act needs async to flush clipboard promises
346+
await act(async () => {
340347
// biome-ignore lint/style/noNonNullAssertion: test assertion
341348
fireEvent.click(tsvBtn!);
342349
});

0 commit comments

Comments
 (0)