mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-05 12:50:29 +02:00
33 lines
880 B
TypeScript
33 lines
880 B
TypeScript
import { EditorView } from '@codemirror/view';
|
|
import { EditorSelection } from '@codemirror/state';
|
|
import swapLine, { SwapLineDirection } from './swapLine';
|
|
|
|
|
|
describe('swapLine', () => {
|
|
it('should swap line down', () => {
|
|
const initialText = 'Hello\nWorld\nJoplin\n';
|
|
const editorView = new EditorView({
|
|
doc: initialText,
|
|
selection: EditorSelection.cursor(0),
|
|
});
|
|
|
|
swapLine(SwapLineDirection.Down)(editorView);
|
|
|
|
const result = editorView.state.doc.toString();
|
|
expect(result).toBe('World\nHello\nJoplin\n');
|
|
});
|
|
|
|
it('should swap line up', () => {
|
|
const initialText = 'Hello\nWorld\nJoplin\n';
|
|
const editorView = new EditorView({
|
|
doc: initialText,
|
|
selection: EditorSelection.cursor(6),
|
|
});
|
|
|
|
swapLine(SwapLineDirection.Up)(editorView);
|
|
|
|
const result = editorView.state.doc.toString();
|
|
expect(result).toBe('World\nHello\nJoplin\n');
|
|
});
|
|
});
|