@@ -11,7 +11,7 @@ import XCTest
11
11
12
12
extension ActiveElement : Equatable { }
13
13
14
- func == ( a: ActiveElement , b: ActiveElement ) -> Bool {
14
+ public func == ( a: ActiveElement , b: ActiveElement ) -> Bool {
15
15
switch ( a, b) {
16
16
case ( . mention( let a) , . mention( let b) ) where a == b: return true
17
17
case ( . hashtag( let a) , . hashtag( let b) ) where a == b: return true
@@ -404,4 +404,33 @@ class ActiveTypeTests: XCTestCase {
404
404
405
405
XCTAssertNotEqual ( text. characters. count, label. text!. characters. count)
406
406
}
407
+
408
+ func testStringTrimmingURLShorterThanLimit( ) {
409
+ let text = " Tweet with short url: https://hello.co "
410
+ label. urlMaximumLength = 30
411
+ label. text = text
412
+
413
+ XCTAssertEqual ( text, label. text!)
414
+ }
415
+
416
+ func testStringTrimmingURLLongerThanLimit( ) {
417
+ let trimLimit = 30
418
+ let url = " https://twitter.com/twicket_app/status/649678392372121601 "
419
+ let trimmedURL = url. trim ( to: trimLimit)
420
+ let text = " Tweet with long url: \( url) "
421
+ label. urlMaximumLength = trimLimit
422
+ label. text = text
423
+
424
+
425
+ XCTAssertNotEqual ( text. characters. count, label. text!. characters. count)
426
+
427
+ switch activeElements. first! {
428
+ case . url( let original, let trimmed) :
429
+ XCTAssertEqual ( original, url)
430
+ XCTAssertEqual ( trimmed, trimmedURL)
431
+ default :
432
+ XCTAssert ( false )
433
+ }
434
+
435
+ }
407
436
}
0 commit comments