mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
32 lines
824 B
TypeScript
32 lines
824 B
TypeScript
import { EditorView } from '@codemirror/view';
|
|
import { EditorSelection } from '@codemirror/state';
|
|
import duplicateLine from './duplicateLine';
|
|
|
|
describe('duplicateLine', () => {
|
|
it('should duplicate line', () => {
|
|
const initialText = 'Hello\nWorld\n';
|
|
const editorView = new EditorView({
|
|
doc: initialText,
|
|
selection: EditorSelection.cursor(0),
|
|
});
|
|
|
|
duplicateLine(editorView);
|
|
|
|
const result = editorView.state.doc.toString();
|
|
expect(result).toBe('Hello\nHello\nWorld\n');
|
|
});
|
|
|
|
it('should duplicate range', () => {
|
|
const initialText = 'Hello\nWorld\n';
|
|
const editorView = new EditorView({
|
|
doc: initialText,
|
|
selection: EditorSelection.range(0, 8),
|
|
});
|
|
|
|
duplicateLine(editorView);
|
|
|
|
const result = editorView.state.doc.toString();
|
|
expect(result).toBe('Hello\nWoHello\nWorld\n');
|
|
});
|
|
});
|