Skip to content

Commit

Permalink
added white space after image promoted to paragraph unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Dec 30, 2012
1 parent f46aeba commit 2f4fc23
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- The img is outside of a block, the 2 causes a new paragraph, but there should be no whitespace between image and \n -->
<p>1</p>
<img class="Bla" style="width:15px; height:15px" src="Oliver.jpg">
<p>2</p>
20 changes: 20 additions & 0 deletions Core/Test/Source/DTHTMLAttributedStringBuilderTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "DTHTMLAttributedStringBuilderTest.h"

#import "DTHTMLAttributedStringBuilder.h"
#import "DTCoreTextConstants.h"

@implementation DTHTMLAttributedStringBuilderTest

Expand All @@ -29,4 +30,23 @@ - (void)testSpaceBetweenUnderlines
STAssertTrue([underLine integerValue]==0, @"Space between a and b should not be underlined");
}

// a block following an inline image should only cause a \n after the image, not whitespace
- (void)testWhitspaceAfterParagraphPromotedImage
{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@"WhitespaceFollowingImagePromotedToParagraph" ofType:@"html"];

NSData *data = [NSData dataWithContentsOfFile:path];

DTHTMLAttributedStringBuilder *builder = [[DTHTMLAttributedStringBuilder alloc] initWithHTML:data options:nil documentAttributes:NULL];

NSAttributedString *output = [builder generatedAttributedString];

STAssertTrue([output length]==6, @"Generated String should be 6 characters");

NSMutableString *expectedOutput = [NSMutableString stringWithFormat:@"1\n%@\n2\n", UNICODE_OBJECT_PLACEHOLDER];

STAssertTrue([expectedOutput isEqualToString:[output string]], @"Expected output not matching");
}

@end

0 comments on commit 2f4fc23

Please sign in to comment.