Skip to content

Commit 0e65585

Browse files
committed
Fix mock view annotations in widgets.test.ts
1 parent 91e2eb1 commit 0e65585

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/lib/editor/widgets.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ describe('Editor Widgets', () => {
2626

2727
describe('CheckboxWidget', () => {
2828
it('should create unchecked DOM correctly', () => {
29-
const mockView = { dispatch: vi.fn() } as unknown as Partial<EditorView> as EditorView
30-
const widget = new CheckboxWidget(false, 10, mockView)
29+
const mockView: Partial<EditorView> = { dispatch: vi.fn() }
30+
const widget = new CheckboxWidget(false, 10, mockView as EditorView)
3131
const dom = widget.toDOM()
3232

3333
expect(dom.className).toBe('cm-checkbox-widget')
3434
expect(dom.innerHTML).toBe('')
3535
})
3636

3737
it('should create checked DOM correctly', () => {
38-
const mockView = { dispatch: vi.fn() } as unknown as Partial<EditorView> as EditorView
39-
const widget = new CheckboxWidget(true, 10, mockView)
38+
const mockView: Partial<EditorView> = { dispatch: vi.fn() }
39+
const widget = new CheckboxWidget(true, 10, mockView as EditorView)
4040
const dom = widget.toDOM()
4141

4242
expect(dom.className).toBe('cm-checkbox-widget cm-checkbox-checked')
4343
expect(dom.querySelector('svg')).not.toBeNull()
4444
})
4545

4646
it('should dispatch correct transaction on click', () => {
47-
const mockView = { dispatch: vi.fn() } as unknown as Partial<EditorView> as EditorView
47+
const mockView: Partial<EditorView> = { dispatch: vi.fn() }
4848

4949
// Unchecked -> Checked
50-
const widgetUnchecked = new CheckboxWidget(false, 10, mockView)
50+
const widgetUnchecked = new CheckboxWidget(false, 10, mockView as EditorView)
5151
const domUnchecked = widgetUnchecked.toDOM()
5252
domUnchecked.onclick?.({
5353
preventDefault: vi.fn(),
@@ -61,7 +61,7 @@ describe('Editor Widgets', () => {
6161
vi.clearAllMocks()
6262

6363
// Checked -> Unchecked
64-
const widgetChecked = new CheckboxWidget(true, 10, mockView)
64+
const widgetChecked = new CheckboxWidget(true, 10, mockView as EditorView)
6565
const domChecked = widgetChecked.toDOM()
6666
domChecked.onclick?.({
6767
preventDefault: vi.fn(),

0 commit comments

Comments
 (0)