Skip to content

Commit

Permalink
Add tests to discard issue #150
Browse files Browse the repository at this point in the history
  • Loading branch information
polqf committed Jan 24, 2017
1 parent 338c06b commit 446dbcd
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion ActiveLabelTests/ActiveTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCTest

extension ActiveElement: Equatable {}

func ==(a: ActiveElement, b: ActiveElement) -> Bool {
public func ==(a: ActiveElement, b: ActiveElement) -> Bool {
switch (a, b) {
case (.mention(let a), .mention(let b)) where a == b: return true
case (.hashtag(let a), .hashtag(let b)) where a == b: return true
Expand Down Expand Up @@ -404,4 +404,33 @@ class ActiveTypeTests: XCTestCase {

XCTAssertNotEqual(text.characters.count, label.text!.characters.count)
}

func testStringTrimmingURLShorterThanLimit() {
let text = "Tweet with short url: https://hello.co"
label.urlMaximumLength = 30
label.text = text

XCTAssertEqual(text, label.text!)
}

func testStringTrimmingURLLongerThanLimit() {
let trimLimit = 30
let url = "https://twitter.com/twicket_app/status/649678392372121601"
let trimmedURL = url.trim(to: trimLimit)
let text = "Tweet with long url: \(url)"
label.urlMaximumLength = trimLimit
label.text = text


XCTAssertNotEqual(text.characters.count, label.text!.characters.count)

switch activeElements.first! {
case .url(let original, let trimmed):
XCTAssertEqual(original, url)
XCTAssertEqual(trimmed, trimmedURL)
default:
XCTAssert(false)
}

}
}

0 comments on commit 446dbcd

Please sign in to comment.