Skip to content

Commit

Permalink
Expanded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhersh committed Feb 25, 2015
1 parent 2331282 commit 83de647
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Example/TTTAttributedLabelTests/TTTAttributedLabelTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ - (void)testInitializable {
- (void)testContentSize {
label.text = TTTAttributedTestString();
expect([label intrinsicContentSize]).to.equal([label sizeThatFits:CGSizeZero]);
label.text = kTestLabelText;
expect([label intrinsicContentSize]).to.equal([label sizeThatFits:CGSizeZero]);
}

- (void)testHighlighting {
Expand All @@ -104,6 +106,8 @@ - (void)testAttributedTextAccess {
}

- (void)testLinkTintColor {
label.tintColor = [UIColor whiteColor];

label.inactiveLinkAttributes = @{ kTTTBackgroundFillColorAttributeName : (id)[UIColor grayColor].CGColor };
label.activeLinkAttributes = @{ kTTTBackgroundFillColorAttributeName : (id)[UIColor redColor].CGColor };
label.text = TTTAttributedTestString();
Expand Down Expand Up @@ -175,6 +179,13 @@ - (void)testMultilineLabelSizing {

UIFont *font = [testString attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL];
XCTAssertGreaterThan(size.height, font.pointSize, @"Text should size to more than one line");

size = [TTTAttributedLabel sizeThatFitsAttributedString:testString
withConstraints:kTestLabelSize
limitedToNumberOfLines:2];

font = [testString attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL];
XCTAssertGreaterThan(size.height, font.pointSize, @"Text should size to more than one line");
}

- (void)testContainsLinkAtPoint {
Expand Down Expand Up @@ -382,6 +393,7 @@ - (void)testAccessibilityElement {
expect(label.isAccessibilityElement).to.beFalsy();
expect(label.accessibilityElementCount).will.equal(2);
expect([label accessibilityElementAtIndex:0]).toNot.beNil();
expect([label indexOfAccessibilityElement:nil]).to.equal(NSNotFound);
}

#pragma mark - TTTAttributedLabelLink tests
Expand Down Expand Up @@ -725,14 +737,24 @@ - (void)testEncodingLabel {
label.text = TTTAttributedTestString();

NSData *encodedLabel = [NSKeyedArchiver archivedDataWithRootObject:label];

TTTAttributedLabel *newLabel = [NSKeyedUnarchiver unarchiveObjectWithData:encodedLabel];

expect(newLabel.text).to.equal(label.text);
}

#pragma mark - TTTAttributedLabelLink

- (void)testAddSingleLink {
TTTAttributedLabelLink *link = [[TTTAttributedLabelLink alloc] initWithAttributesFromLabel:label
textCheckingResult:
[NSTextCheckingResult linkCheckingResultWithRange:NSMakeRange(0, 1) URL:testURL]];

[label addLink:link];

expect(label.links.count).to.equal(1);
}

- (void)testEncodingLink {
TTTAttributedLabelLink *link = [[TTTAttributedLabelLink alloc] initWithAttributesFromLabel:label
textCheckingResult:
Expand Down

0 comments on commit 83de647

Please sign in to comment.