File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Tests/ParagraphTextKitTests Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1296,6 +1296,30 @@ final class ParagraphTextStorageTests: XCTestCase {
1296
1296
" ParagraphTextStorage paragraph ranges should match the delegate ranges " )
1297
1297
}
1298
1298
1299
+ func testParagraphTextStorage_DeleteAllParagraphs( ) {
1300
+ let string = " First paragraph \n Second paragraph \n Third paragraph "
1301
+
1302
+ textStorage. beginEditing ( )
1303
+ textStorage. replaceCharacters ( in: NSRange ( location: 0 , length: 0 ) , with: string)
1304
+ textStorage. endEditing ( )
1305
+
1306
+ textStorage. beginEditing ( )
1307
+ textStorage. replaceCharacters ( in: NSRange ( location: 0 , length: string. length) , with: " " )
1308
+ textStorage. endEditing ( )
1309
+
1310
+ XCTAssertTrue ( delegate. insertions. count == 2 && delegate. editions. count == 2 && delegate. removals. count == 2 ,
1311
+ " ParagraphTextStorage paragraph delegate should be notified of exact changes " )
1312
+
1313
+ XCTAssertTrue ( delegate. insertions [ 0 ] == 1 && delegate. insertions [ 1 ] == 2 )
1314
+ XCTAssertTrue ( delegate. editions [ 0 ] == 0 && delegate. editions [ 1 ] == 0 )
1315
+ XCTAssertTrue ( delegate. removals [ 0 ] == 2 )
1316
+ XCTAssertTrue ( delegate. removals [ 1 ] == 1 )
1317
+
1318
+ XCTAssertTrue ( textStorage. paragraphRanges. count == 1 ,
1319
+ " ParagraphTextStorage should now have 1 paragraphs " )
1320
+ XCTAssertTrue ( delegate. paragraphs [ 0 ] . isEmpty)
1321
+ }
1322
+
1299
1323
1300
1324
// MARK: - Mixed Tests
1301
1325
You can’t perform that action at this time.
0 commit comments