Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added white space after image promoted to paragraph unit test

  • Loading branch information...
commit 2f4fc23db8f9cc20c2153b9f1accc060ec2dab7d 1 parent f46aeba
@Cocoanetics authored
View
4 Core/Test/Resources/WhitespaceFollowingImagePromotedToParagraph.html
@@ -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>
View
20 Core/Test/Source/DTHTMLAttributedStringBuilderTest.m
@@ -9,6 +9,7 @@
#import "DTHTMLAttributedStringBuilderTest.h"
#import "DTHTMLAttributedStringBuilder.h"
+#import "DTCoreTextConstants.h"
@implementation DTHTMLAttributedStringBuilderTest
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.