11import 'reflect-metadata' ;
22import { container } from 'tsyringe' ;
33import { PanelService } from '../workbench/panelService' ;
4+ import { StandaloneEditor } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneCodeEditor' ;
45import { PanelEvent } from 'mo/model/workbench/panel' ;
56import { expectLoggerErrorToBeCalled } from '@test/utils' ;
67import { modules } from '../builtinService/const' ;
@@ -13,6 +14,15 @@ const restore = modules.builtInPanelToolboxReStore();
1314
1415const panelService = container . resolve ( PanelService ) ;
1516
17+ jest . mock (
18+ 'monaco-editor/esm/vs/editor/standalone/browser/standaloneCodeEditor' ,
19+ ( ) => {
20+ return {
21+ StandaloneEditor : class { } ,
22+ } ;
23+ }
24+ ) ;
25+
1626describe ( 'The PanelService test' , ( ) => {
1727 afterEach ( ( ) => {
1828 panelService . reset ( ) ;
@@ -128,20 +138,20 @@ describe('The PanelService test', () => {
128138 } ) ;
129139
130140 test ( 'Should NOT clone StandaloneEditor when get the panel' , ( ) => {
131- class StandaloneEditor { }
132- const standaloneEditor = new StandaloneEditor ( ) ;
133141 panelService . setState ( {
134142 data : [
135143 {
136144 ...paneOutput ,
137- outputEditorInstance : standaloneEditor ,
145+ outputEditorInstance : new StandaloneEditor ( ) ,
138146 } as any ,
139147 ] ,
140148 } ) ;
141149
142150 const target = panelService . getPanel ( paneOutput . id ) ;
143151 expect ( target ) . toEqual ( expect . objectContaining ( paneOutput ) ) ;
144- expect ( ( target as any ) . outputEditorInstance ) . toBe ( standaloneEditor ) ;
152+ expect ( ( target as any ) . outputEditorInstance ) . toBeInstanceOf (
153+ StandaloneEditor
154+ ) ;
145155 } ) ;
146156
147157 test ( 'Should support to active a exist panel' , ( ) => {
0 commit comments