|
|
@@ -52,19 +52,25 @@ describe( 'IndentCommand', () => {
|
|
|
|
|
|
describe( 'isEnabled', () => {
|
|
|
it( 'should be true if selection starts in list item', () => {
|
|
|
- doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ } );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should be false if selection starts in first list item', () => {
|
|
|
- doc.selection.collapse( root.getChild( 0 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 0 ) );
|
|
|
+ } );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
it( 'should be false if selection starts in a list item that has bigger indent than it\'s previous sibling', () => {
|
|
|
- doc.selection.collapse( root.getChild( 2 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 2 ) );
|
|
|
+ } );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
} );
|
|
|
@@ -73,6 +79,7 @@ describe( 'IndentCommand', () => {
|
|
|
// and before we fixed it the command was enabled in such a case.
|
|
|
it( 'should be false if selection starts in a paragraph with indent attribute', () => {
|
|
|
doc.schema.allow( { name: 'paragraph', attributes: [ 'indent' ], inside: '$root' } );
|
|
|
+
|
|
|
setData( doc, '<listItem indent="0">a</listItem><paragraph indent="0">b[]</paragraph>' );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
@@ -81,7 +88,9 @@ describe( 'IndentCommand', () => {
|
|
|
|
|
|
describe( '_doExecute', () => {
|
|
|
it( 'should increment indent attribute by 1', () => {
|
|
|
- doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -97,7 +106,9 @@ describe( 'IndentCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should increment indent of all sub-items of indented item', () => {
|
|
|
- doc.selection.collapse( root.getChild( 1 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 1 ) );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -113,10 +124,12 @@ describe( 'IndentCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should increment indent of all selected item when multiple items are selected', () => {
|
|
|
- doc.selection.setRanges( [ new Range(
|
|
|
- new Position( root.getChild( 1 ), [ 0 ] ),
|
|
|
- new Position( root.getChild( 3 ), [ 0 ] )
|
|
|
- ) ] );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.setRanges( [ new Range(
|
|
|
+ new Position( root.getChild( 1 ), [ 0 ] ),
|
|
|
+ new Position( root.getChild( 3 ), [ 0 ] )
|
|
|
+ ) ] );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -137,13 +150,9 @@ describe( 'IndentCommand', () => {
|
|
|
'<listItem indent="0" type="bulleted">a</listItem>' +
|
|
|
'<listItem indent="1" type="bulleted">b</listItem>' +
|
|
|
'<listItem indent="2" type="numbered">c</listItem>' +
|
|
|
- '<listItem indent="1" type="bulleted">d</listItem>'
|
|
|
+ '<listItem indent="1" type="bulleted">[]d</listItem>'
|
|
|
);
|
|
|
|
|
|
- doc.selection.setRanges( [ new Range(
|
|
|
- new Position( root.getChild( 3 ), [ 0 ] )
|
|
|
- ) ] );
|
|
|
-
|
|
|
command._doExecute();
|
|
|
|
|
|
expect( getData( doc, { withoutSelection: true } ) ).to.equal(
|
|
|
@@ -169,21 +178,27 @@ describe( 'IndentCommand', () => {
|
|
|
|
|
|
describe( 'isEnabled', () => {
|
|
|
it( 'should be true if selection starts in list item', () => {
|
|
|
- doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ } );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should be true if selection starts in first list item', () => {
|
|
|
// This is in contrary to forward indent command.
|
|
|
- doc.selection.collapse( root.getChild( 0 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 0 ) );
|
|
|
+ } );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should be true if selection starts in a list item that has bigger indent than it\'s previous sibling', () => {
|
|
|
// This is in contrary to forward indent command.
|
|
|
- doc.selection.collapse( root.getChild( 2 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 2 ) );
|
|
|
+ } );
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
|
@@ -191,7 +206,9 @@ describe( 'IndentCommand', () => {
|
|
|
|
|
|
describe( '_doExecute', () => {
|
|
|
it( 'should decrement indent attribute by 1 (if it is bigger than 0)', () => {
|
|
|
- doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 5 ) );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -207,7 +224,9 @@ describe( 'IndentCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should rename listItem to paragraph (if indent is equal to 0)', () => {
|
|
|
- doc.selection.collapse( root.getChild( 0 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 0 ) );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -223,7 +242,9 @@ describe( 'IndentCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should decrement indent of all sub-items of outdented item', () => {
|
|
|
- doc.selection.collapse( root.getChild( 1 ) );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.collapse( root.getChild( 1 ) );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -239,10 +260,12 @@ describe( 'IndentCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should outdent all selected item when multiple items are selected', () => {
|
|
|
- doc.selection.setRanges( [ new Range(
|
|
|
- new Position( root.getChild( 1 ), [ 0 ] ),
|
|
|
- new Position( root.getChild( 3 ), [ 0 ] )
|
|
|
- ) ] );
|
|
|
+ doc.enqueueChanges( () => {
|
|
|
+ doc.selection.setRanges( [ new Range(
|
|
|
+ new Position( root.getChild( 1 ), [ 0 ] ),
|
|
|
+ new Position( root.getChild( 3 ), [ 0 ] )
|
|
|
+ ) ] );
|
|
|
+ } );
|
|
|
|
|
|
command._doExecute();
|
|
|
|
|
|
@@ -262,13 +285,9 @@ describe( 'IndentCommand', () => {
|
|
|
doc,
|
|
|
'<listItem indent="0" type="bulleted">a</listItem>' +
|
|
|
'<listItem indent="1" type="bulleted">b</listItem>' +
|
|
|
- '<listItem indent="2" type="numbered">c</listItem>'
|
|
|
+ '<listItem indent="2" type="numbered">[]c</listItem>'
|
|
|
);
|
|
|
|
|
|
- doc.selection.setRanges( [ new Range(
|
|
|
- new Position( root.getChild( 2 ), [ 0 ] )
|
|
|
- ) ] );
|
|
|
-
|
|
|
command._doExecute();
|
|
|
|
|
|
expect( getData( doc, { withoutSelection: true } ) ).to.equal(
|
|
|
@@ -277,25 +296,6 @@ describe( 'IndentCommand', () => {
|
|
|
'<listItem indent="1" type="bulleted">c</listItem>'
|
|
|
);
|
|
|
} );
|
|
|
-
|
|
|
- it( 'should not fix list type if item is outdented to top level', () => {
|
|
|
- setData(
|
|
|
- doc,
|
|
|
- '<listItem indent="0" type="bulleted">a</listItem>' +
|
|
|
- '<listItem indent="1" type="numbered">b</listItem>'
|
|
|
- );
|
|
|
-
|
|
|
- doc.selection.setRanges( [ new Range(
|
|
|
- new Position( root.getChild( 1 ), [ 0 ] )
|
|
|
- ) ] );
|
|
|
-
|
|
|
- command._doExecute();
|
|
|
-
|
|
|
- expect( getData( doc, { withoutSelection: true } ) ).to.equal(
|
|
|
- '<listItem indent="0" type="bulleted">a</listItem>' +
|
|
|
- '<listItem indent="0" type="numbered">b</listItem>'
|
|
|
- );
|
|
|
- } );
|
|
|
} );
|
|
|
} );
|
|
|
} );
|