Skip to content

Commit ac9d577

Browse files
mortalYoungmumiao
authored andcommitted
test: update test
1 parent 32641b9 commit ac9d577

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/services/__tests__/panelService.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'reflect-metadata';
22
import { container } from 'tsyringe';
33
import { PanelService } from '../workbench/panelService';
4+
import { StandaloneEditor } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneCodeEditor';
45
import { PanelEvent } from 'mo/model/workbench/panel';
56
import { expectLoggerErrorToBeCalled } from '@test/utils';
67
import { modules } from '../builtinService/const';
@@ -13,6 +14,15 @@ const restore = modules.builtInPanelToolboxReStore();
1314

1415
const 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+
1626
describe('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

Comments
 (0)