Skip to content

Commit

Permalink
Added unit tests for Cocoanetics#738
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Jul 4, 2014
1 parent 4526ee7 commit 6e10dbf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Test/Source/DTHTMLAttributedStringBuilderTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,15 @@ - (void)testDisplayStyleInheritance
XCTAssertTrue([lines count]==1, @"There should only be one line, display style block should not be inherited");
}

#pragma mark - Attachments

// issue 738: Attachments with display:none should not show
- (void)testAttachmentWithDisplayNone
{
NSAttributedString *attributedString = [self attributedStringFromHTMLString:@"<img style=\"display:none;\" src=\"Oliver.jpg\">" options:nil];
XCTAssertEqual([attributedString length], 0, @"Text attachment should be invisible");
}

#pragma mark - Parsing Options

// issue 649
Expand Down
21 changes: 21 additions & 0 deletions Test/Source/DTHTMLElementTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,25 @@ - (void)testCombiningWebKitAndNormalMargin
XCTAssertEqual(element.margins.bottom, 20, @"Incorrect bottom margin");
}

// issue 738: Attachments with display:none should not show
- (void)testAttachmentWithDisplayNone
{
DTHTMLElement *element = [[DTHTMLElement alloc] init];
element.textScale = 1;
element.paragraphStyle = [DTCoreTextParagraphStyle defaultParagraphStyle];
CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica"), 20, NULL);
element.fontDescriptor = [DTCoreTextFontDescriptor fontDescriptorForCTFont:font];
CFRelease(font);

DTObjectTextAttachment *object = [[DTObjectTextAttachment alloc] initWithElement:element options:nil];
element.textAttachment = object;

NSDictionary *styles = @{@"display" : @"none"};
[element applyStyleDictionary:styles];

NSAttributedString *attributedString = [element attributedString];

XCTAssertNil(attributedString, @"Text attachment should be invisible");
}

@end

0 comments on commit 6e10dbf

Please sign in to comment.