-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cm.spec.ts
32 lines (27 loc) · 839 Bytes
/
cm.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { describe, it, expect } from 'vitest';
import { EditorState } from 'prosemirror-state';
import { EditorView } from 'prosemirror-view';
import schema from './demo/schema';
import doc from './demo/doc';
import { CodeMirrorView } from './lib';
describe('CodeMirror', () => {
it('should render codemirror editor', () => {
const element = document.createElement('pm-root');
const state = EditorState.create({
doc: schema.nodeFromJSON(doc),
schema,
});
const editor = new EditorView(element, {
state,
nodeViews: {
code_mirror: (node: any, view: any, getPos: any) => new CodeMirrorView({
node,
view,
getPos,
}),
},
});
expect(editor).toBeTruthy();
expect(element.getElementsByClassName('cm-editor')).toHaveLength(1);
});
});