Skip to content

Commit 446dbcd

Browse files
committed
Add tests to discard issue #150
1 parent 338c06b commit 446dbcd

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

ActiveLabelTests/ActiveTypeTests.swift

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import XCTest
1111

1212
extension ActiveElement: Equatable {}
1313

14-
func ==(a: ActiveElement, b: ActiveElement) -> Bool {
14+
public func ==(a: ActiveElement, b: ActiveElement) -> Bool {
1515
switch (a, b) {
1616
case (.mention(let a), .mention(let b)) where a == b: return true
1717
case (.hashtag(let a), .hashtag(let b)) where a == b: return true
@@ -404,4 +404,33 @@ class ActiveTypeTests: XCTestCase {
404404

405405
XCTAssertNotEqual(text.characters.count, label.text!.characters.count)
406406
}
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+
}
407436
}

0 commit comments

Comments
 (0)