Skip to content

Commit

Permalink
[Changed] ImageAttachment test
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanhuang13 committed Jul 11, 2019
1 parent 5f129b0 commit e8cdcad
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@
import XCTest

final class ImageAttachmentTests: XCTestCase {
func testSetImage() {
func testSetImage_getAttachmentAttribute() {
let testBundle = Bundle(for: ImageAttachmentTests.self)
let testImage = UIImage(contentsOfFile: testBundle.path(forResource: "Swift_logo_color_rgb", ofType: "jpg")!)!

let testData: NSAttributedString = {
let mas = NSMutableAttributedString(string: "Hello world")
let attachment = NSTextAttachment()
attachment.image = testImage
attachment.bounds = CGRect(x: 0, y: 0, width: 40, height: 40)
mas.append(NSAttributedString(attachment: attachment))
return mas
}()

let sut = NSAttributedString {
AttrText("Hello world")
ImageAttachment(testImage, size: CGSize(width: 40, height: 40))
AttrText.linebreak
}

XCTAssertTrue(sut.isEqual(testData))
XCTAssertNotNil(sut.attributes(at: 0, effectiveRange: nil)[.attachment])
// TODO: Better test
}
}

0 comments on commit e8cdcad

Please sign in to comment.