Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge branch t/ckeditor5-engine/1209
Browse files Browse the repository at this point in the history
Internal: Update API usage after merge t/1209 on engine.
  • Loading branch information
Piotr Jasiun committed Jan 29, 2018
2 parents e4ac704 + 2f27560 commit 804f85d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 49 deletions.
60 changes: 30 additions & 30 deletions tests/indentcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ describe( 'IndentCommand', () => {

describe( 'isEnabled', () => {
it( 'should be true if selection starts in list item', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 5 ) );
model.change( writer => {
writer.setSelection( root.getChild( 5 ) );
} );

expect( command.isEnabled ).to.be.true;
} );

it( 'should be false if selection starts in first list item', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 0 ) );
model.change( writer => {
writer.setSelection( root.getChild( 0 ) );
} );

expect( command.isEnabled ).to.be.false;
Expand Down Expand Up @@ -106,8 +106,8 @@ describe( 'IndentCommand', () => {
} );

it( 'should be false if selection starts in a list item that has bigger indent than it\'s previous sibling', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 2 ) );
model.change( writer => {
writer.setSelection( root.getChild( 2 ) );
} );

expect( command.isEnabled ).to.be.false;
Expand All @@ -126,8 +126,8 @@ describe( 'IndentCommand', () => {

describe( 'execute()', () => {
it( 'should use parent batch', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 5 ) );
model.change( writer => {
writer.setSelection( root.getChild( 5 ) );
} );

model.change( writer => {
Expand All @@ -140,8 +140,8 @@ describe( 'IndentCommand', () => {
} );

it( 'should increment indent attribute by 1', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 5 ) );
model.change( writer => {
writer.setSelection( root.getChild( 5 ) );
} );

command.execute();
Expand All @@ -158,8 +158,8 @@ describe( 'IndentCommand', () => {
} );

it( 'should increment indent of all sub-items of indented item', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 1 ) );
model.change( writer => {
writer.setSelection( root.getChild( 1 ) );
} );

command.execute();
Expand All @@ -176,11 +176,11 @@ describe( 'IndentCommand', () => {
} );

it( 'should increment indent of all selected item when multiple items are selected', () => {
model.change( () => {
doc.selection.setRanges( [ new Range(
model.change( writer => {
writer.setSelection( new Range(
new Position( root.getChild( 1 ), [ 0 ] ),
new Position( root.getChild( 3 ), [ 1 ] )
) ] );
) );
} );

command.execute();
Expand Down Expand Up @@ -211,26 +211,26 @@ describe( 'IndentCommand', () => {

describe( 'isEnabled', () => {
it( 'should be true if selection starts in list item', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 5 ) );
model.change( writer => {
writer.setSelection( 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.
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 0 ) );
model.change( writer => {
writer.setSelection( 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.
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 2 ) );
model.change( writer => {
writer.setSelection( root.getChild( 2 ) );
} );

expect( command.isEnabled ).to.be.true;
Expand All @@ -239,8 +239,8 @@ describe( 'IndentCommand', () => {

describe( 'execute()', () => {
it( 'should decrement indent attribute by 1 (if it is bigger than 0)', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 5 ) );
model.change( writer => {
writer.setSelection( root.getChild( 5 ) );
} );

command.execute();
Expand All @@ -257,8 +257,8 @@ describe( 'IndentCommand', () => {
} );

it( 'should rename listItem to paragraph (if indent is equal to 0)', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 0 ) );
model.change( writer => {
writer.setSelection( root.getChild( 0 ) );
} );

command.execute();
Expand All @@ -275,8 +275,8 @@ describe( 'IndentCommand', () => {
} );

it( 'should decrement indent of all sub-items of outdented item', () => {
model.change( () => {
doc.selection.setCollapsedAt( root.getChild( 1 ) );
model.change( writer => {
writer.setSelection( root.getChild( 1 ) );
} );

command.execute();
Expand All @@ -293,11 +293,11 @@ describe( 'IndentCommand', () => {
} );

it( 'should outdent all selected item when multiple items are selected', () => {
model.change( () => {
doc.selection.setRanges( [ new Range(
model.change( writer => {
writer.setSelection( new Range(
new Position( root.getChild( 1 ), [ 0 ] ),
new Position( root.getChild( 3 ), [ 1 ] )
) ] );
) );
} );

command.execute();
Expand Down
40 changes: 21 additions & 19 deletions tests/listcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ describe( 'ListCommand', () => {
'</widget>'
);

doc.selection.setCollapsedAt( doc.getRoot().getChild( 0 ) );
model.change( writer => {
writer.setSelection( doc.getRoot().getChild( 0 ) );
} );
} );

afterEach( () => {
Expand All @@ -70,24 +72,24 @@ describe( 'ListCommand', () => {

describe( 'value', () => {
it( 'should be false if first position in selection is not in a list item', () => {
model.change( () => {
doc.selection.setCollapsedAt( doc.getRoot().getChild( 3 ) );
model.change( writer => {
writer.setSelection( doc.getRoot().getChild( 3 ) );
} );

expect( command.value ).to.be.false;
} );

it( 'should be false if first position in selection is in a list item of different type', () => {
model.change( () => {
doc.selection.setCollapsedAt( doc.getRoot().getChild( 2 ) );
model.change( writer => {
writer.setSelection( doc.getRoot().getChild( 2 ) );
} );

expect( command.value ).to.be.false;
} );

it( 'should be true if first position in selection is in a list item of same type', () => {
model.change( () => {
doc.selection.setCollapsedAt( doc.getRoot().getChild( 1 ) );
model.change( writer => {
writer.setSelection( doc.getRoot().getChild( 1 ) );
} );

expect( command.value ).to.be.true;
Expand Down Expand Up @@ -303,11 +305,11 @@ describe( 'ListCommand', () => {
it( 'should rename closest block to listItem and set correct attributes', () => {
// From first paragraph to second paragraph.
// Command value=false, we are turning on list items.
model.change( () => {
doc.selection.setRanges( [ new Range(
model.change( writer => {
writer.setSelection( new Range(
Position.createAt( root.getChild( 2 ) ),
Position.createAt( root.getChild( 3 ), 'end' )
) ] );
) );
} );

command.execute();
Expand All @@ -328,11 +330,11 @@ describe( 'ListCommand', () => {
it( 'should rename closest listItem to paragraph', () => {
// From second bullet list item to first numbered list item.
// Command value=true, we are turning off list items.
model.change( () => {
doc.selection.setRanges( [ new Range(
model.change( writer => {
writer.setSelection( new Range(
Position.createAt( root.getChild( 1 ) ),
Position.createAt( root.getChild( 4 ), 'end' )
) ] );
) );
} );

// Convert paragraphs, leave numbered list items.
Expand All @@ -353,11 +355,11 @@ describe( 'ListCommand', () => {

it( 'should change closest listItem\'s type', () => {
// From first numbered lsit item to third bulleted list item.
model.change( () => {
doc.selection.setRanges( [ new Range(
model.change( writer => {
writer.setSelection( new Range(
Position.createAt( root.getChild( 4 ) ),
Position.createAt( root.getChild( 6 ) )
) ] );
) );
} );

// Convert paragraphs, leave numbered list items.
Expand All @@ -378,11 +380,11 @@ describe( 'ListCommand', () => {

it( 'should handle outdenting sub-items when list item is turned off', () => {
// From first numbered list item to third bulleted list item.
model.change( () => {
doc.selection.setRanges( [ new Range(
model.change( writer => {
writer.setSelection( new Range(
Position.createAt( root.getChild( 1 ) ),
Position.createAt( root.getChild( 5 ), 'end' )
) ] );
) );
} );

// Convert paragraphs, leave numbered list items.
Expand Down

0 comments on commit 804f85d

Please sign in to comment.