1- import { expect , test , describe , beforeEach , spyOn , mock } from "bun:test" ;
1+ import { expect , test , describe , beforeEach , afterEach , spyOn , mock } from "bun:test" ;
22import "./setup" ;
33import { EditorManager } from "../src/mainview/editor/EditorManager" ;
44import { state } from "../src/mainview/state/workspace" ;
@@ -53,24 +53,22 @@ describe("EditorManager", () => {
5353
5454 test ( "init should create editor instance and bind events" , async ( ) => {
5555 const editorEl = document . getElementById ( "editor" ) as HTMLElement ;
56- EditorManager . init ( editorEl ) ;
56+ const editor = EditorManager . init ( editorEl ) ;
5757
58- expect ( state . editor ) . toBeDefined ( ) ;
58+ expect ( state . editor ) . toBe ( editor ) ;
5959 expect ( state . editor instanceof MockEditor ) . toBe ( true ) ;
60-
61- const autoSaveToggle = document . getElementById ( "autoSaveToggle" ) as HTMLInputElement ;
62- expect ( autoSaveToggle ) . toBeDefined ( ) ;
60+ expect ( state . editor ! . options . element ) . toBe ( editorEl ) ;
6361 } ) ;
6462
6563 test ( "getHTML/setContent should work" , async ( ) => {
6664 const editorEl = document . getElementById ( "editor" ) as HTMLElement ;
6765 EditorManager . init ( editorEl ) ;
6866
6967 const testHtml = "<h1>Test</h1>" ;
70- ( state . editor . commands . setContent as any ) . mockClear ( ) ;
68+ ( state . editor ! . commands . setContent as any ) . mockClear ( ) ;
7169
7270 await EditorManager . setContent ( testHtml ) ;
73- expect ( state . editor . commands . setContent ) . toHaveBeenCalledWith ( testHtml ) ;
71+ expect ( state . editor ! . commands . setContent ) . toHaveBeenCalledWith ( testHtml ) ;
7472
7573 const content = EditorManager . getHTML ( ) ;
7674 expect ( content ) . toBe ( "<p>mock content</p>" ) ;
@@ -85,7 +83,7 @@ describe("EditorManager", () => {
8583 state . openTabs . set ( "test.md" , { filePath : "test.md" , isDirty : false } ) ;
8684
8785 // Trigger update
88- ( EditorManager as any ) . handleUpdate ( state . editor ) ;
86+ ( EditorManager as any ) . handleUpdate ( state . editor ! ) ;
8987
9088 // Wait for auto-save timeout (2000ms in EditorManager)
9189 return new Promise < void > ( ( resolve ) => {
0 commit comments