UNPKG

@ryusei/code

Version:

<div align="center"> <a href="https://code.ryuseijs.com"> <img alt="RyuseiCode" src="https://code.ryuseijs.com/images/svg/logo.svg" width="70"> </a>

30 lines (22 loc) 875 B
import { CODE_TRIPLE_NUMBERS, init, refresh } from '../../../test'; describe( 'Edit#cutLine()', () => { const Editor = init( CODE_TRIPLE_NUMBERS ); const { Selection, Edit } = Editor.Components; const { lines } = Editor.Components.Code; // Suppresses the error dialog. Object.defineProperty( Editor.require( 'Dialog' ), 'message', { value: () => 0 } ); beforeEach( () => { refresh( Editor, CODE_TRIPLE_NUMBERS ); } ); test( 'can cut the current line.', () => { Selection.set( [ 1, 1 ], [ 1, 1 ] ); Edit.cutLine(); expect( lines[ 0 ].text ).toBe( '123' ); expect( lines[ 1 ].text ).toBe( '789' ); } ); test( 'should set the selection at the start of the line.', () => { Selection.set( [ 1, 1 ], [ 1, 1 ] ); Edit.cutLine(); expect( Selection.get().start ).toEqual( [ 1, 0 ] ); } ); } );