mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-05-16 21:43:37 +00:00
32 lines
862 B
TypeScript
32 lines
862 B
TypeScript
/*
|
||
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
||
*
|
||
* Copyright (C) 2025 Tencent.
|
||
*/
|
||
import { describe, expect, test, vi } from 'vitest';
|
||
|
||
import getMonaco from '@editor/utils/monaco-editor';
|
||
|
||
vi.mock('emmet-monaco-es', () => ({
|
||
emmetHTML: vi.fn(),
|
||
emmetCSS: vi.fn(),
|
||
}));
|
||
|
||
vi.mock('monaco-editor', () => ({
|
||
default: { editor: {}, languages: {} },
|
||
editor: {},
|
||
languages: {},
|
||
}));
|
||
|
||
describe('monaco-editor 加载器', () => {
|
||
test('返回 Promise,且会缓存复用同一个实例', async () => {
|
||
const p1 = getMonaco();
|
||
const p2 = getMonaco();
|
||
expect(p1).toBe(p2);
|
||
const monaco = await p1;
|
||
const emmet = await import('emmet-monaco-es');
|
||
expect(emmet.emmetHTML).toHaveBeenCalledWith(monaco);
|
||
expect(emmet.emmetCSS).toHaveBeenCalledWith(monaco, ['css', 'scss']);
|
||
});
|
||
});
|