Skip to content

Commit

Permalink
Added unit test for Cocoanetics#738
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Jul 4, 2014
1 parent 9c703b9 commit f251e48
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Test/Source/DTHTMLAttributedStringBuilderTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,25 @@ - (void)testAttachmentWithDisplayNone
XCTAssertEqual([attributedString length], 0, @"Text attachment should be invisible");
}

// issue 738: Attachment with display:none would cause incorrect needsOutput return
- (void)testDoubleOutputOfAttachmentWithDisplayNone
{
NSAttributedString *attributedString = [self attributedStringFromHTMLString:@"<oliver style=\"width:40; height:40;display:none;\"><p><strong>BOX1</strong></p></oliver><oliver style=\"width:40; height:40;display:block;\"><p><strong>BOX2</strong></p></oliver><p>END</p>" options:nil];

NSRange effectiveRange;
id attachment = [attributedString attribute:NSAttachmentAttributeName atIndex:0 effectiveRange:&effectiveRange];

XCTAssertNotNil(attachment, @"There should be an attachment");
XCTAssertTrue(NSEqualRanges(effectiveRange, NSMakeRange(0, 1)), @"Attachment should only be on first character");

for (NSInteger i=1; i<[attributedString length]; i++)
{
id otherAttachment = [attributedString attribute:NSAttachmentAttributeName atIndex:i effectiveRange:&effectiveRange];
XCTAssertNil(otherAttachment, @"There is an unexpected attachment at %@", NSStringFromRange(effectiveRange));
}
}


#pragma mark - Parsing Options

// issue 649
Expand Down

0 comments on commit f251e48

Please sign in to comment.