diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index 14c2afd93..975843fff 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -1145,7 +1145,7 @@ - (void)setTruncationMode:(NSLineBreakMode)truncationMode - (BOOL)isTruncated { - return ASLockedSelf([self locked_textLayoutForSize:[self _locked_threadSafeBounds].size].truncatedLine == nil); + return ASLockedSelf([self locked_textLayoutForSize:[self _locked_threadSafeBounds].size].truncatedLine != nil); } - (BOOL)shouldTruncateForConstrainedSize:(ASSizeRange)constrainedSize diff --git a/Tests/ASTextNode2Tests.mm b/Tests/ASTextNode2Tests.mm index 2bc513af0..c54cae2ec 100644 --- a/Tests/ASTextNode2Tests.mm +++ b/Tests/ASTextNode2Tests.mm @@ -12,6 +12,7 @@ #import #import +#import #import @@ -63,6 +64,14 @@ - (void)setUp _textNode.attributedText = _attributedText; } +- (void)testTruncation +{ + XCTAssertTrue([(ASTextNode *)_textNode shouldTruncateForConstrainedSize:ASSizeRangeMake(CGSizeMake(100, 100))], @"Text Node should truncate"); + + _textNode.frame = CGRectMake(0, 0, 100, 100); + XCTAssertTrue(_textNode.isTruncated, @"Text Node should be truncated"); +} + - (void)testAccessibility { XCTAssertTrue(_textNode.isAccessibilityElement, @"Should be an accessibility element"); diff --git a/Tests/ASTextNodeTests.mm b/Tests/ASTextNodeTests.mm index 0dc5137a6..4580ade98 100644 --- a/Tests/ASTextNodeTests.mm +++ b/Tests/ASTextNodeTests.mm @@ -16,6 +16,7 @@ #import #import #import +#import #import #import @@ -102,6 +103,14 @@ - (void)testAllocASTextNode #pragma mark - ASTextNode +- (void)testTruncation +{ + XCTAssertTrue([_textNode shouldTruncateForConstrainedSize:ASSizeRangeMake(CGSizeMake(100, 100))], @""); + + _textNode.frame = CGRectMake(0, 0, 100, 100); + XCTAssertTrue(_textNode.isTruncated, @"Text Node should be truncated"); +} + - (void)testSettingTruncationMessage { NSAttributedString *truncation = [[NSAttributedString alloc] initWithString:@"..." attributes:nil];