瀏覽代碼

Updated table selection assertion.

Kuba Niegowski 5 年之前
父節點
當前提交
04670185a3
共有 1 個文件被更改,包括 20 次插入17 次删除
  1. 20 17
      packages/ckeditor5-table/tests/tableclipboard-paste.js

+ 20 - 17
packages/ckeditor5-table/tests/tableclipboard-paste.js

@@ -3434,25 +3434,28 @@ describe( 'table clipboard', () => {
 					[ '40', '41', '42', '43', '44' ]
 				], { headingRows: 2, headingColumns: 2 } ) );
 
-				const selectionRanges = Array.from( model.document.selection.getRanges() );
-				const selectedCellsPaths = selectionRanges.map( ( { start } ) => start.path );
-
-				// Note that order of ranges is also important.
-				expect( selectionRanges.length ).to.be.equal( 11 );
-				expect( selectedCellsPaths ).to.deep.equal( [
-					[ 0, 0, 0 ],
-					[ 0, 0, 1 ],
-					[ 0, 0, 2 ],
-					[ 0, 1, 0 ],
-					[ 0, 2, 0 ],
-					[ 0, 2, 1 ],
-					[ 0, 2, 2 ],
-					[ 0, 3, 0 ],
-					[ 0, 3, 1 ],
-					[ 0, 3, 2 ],
-					[ 0, 3, 3 ]
+				assertSelectionRangesSorted();
+
+				/* eslint-disable no-multi-spaces */
+				assertSelectedCells( model, [
+					[ 1,    1, 1, 0 ],
+					[          1, 0 ],
+					[ 1,    1, 1, 0 ],
+					[ 1, 1, 1, 1, 0 ],
+					[ 0, 0, 0, 0, 0 ]
 				] );
+				/* eslint-enable no-multi-spaces */
 			} );
+
+			function assertSelectionRangesSorted() {
+				const selectionRanges = Array.from( model.document.selection.getRanges() );
+				const selectionRangesSorted = selectionRanges.slice().sort( ( a, b ) => a.start.isBefore( b.start ) ? -1 : 1 );
+
+				const selectionPaths = selectionRanges.map( ( { start } ) => start.path );
+				const sortedPaths = selectionRangesSorted.map( ( { start } ) => start.path );
+
+				expect( selectionPaths ).to.deep.equal( sortedPaths );
+			}
 		} );
 	} );