Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values for line break mode and alignment #16

Merged
merged 7 commits into from
Dec 1, 2019

Conversation

artemnovichkov
Copy link
Contributor

By default UILabel uses .natural text alignment and .byTruncatingTail line break mode. To leave default behaviour as is I added these default values to all styles. Related to #13

@artemnovichkov artemnovichkov added the enhancement New feature or request label Nov 26, 2019
//When
let copy = attributes.copy()
//Then
XCTAssertEqual(copy, attributes, "Copy is not equal to line attributes")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Copy is not equal to line attributes"

NOT equal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, this message contains a description what was wrong in this assertion


//Then
XCTAssertEqual(style.font, .systemFont(ofSize: 12), "Default style font must be equal to system font of 12 size")
XCTAssertEqual(style.color, .black, "Default color must be equal to nil")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
XCTAssertEqual(style.color, .black, "Default color must be equal to nil")
XCTAssertEqual(style.color, .black, "Default color must be equal to black")

//Then
XCTAssertEqual(style.font, .systemFont(ofSize: 12), "Default style font must be equal to system font of 12 size")
XCTAssertEqual(style.color, .black, "Default color must be equal to nil")
XCTAssertEqual(style.backgroundColor, .clear, "Default backgroundColor must be equal to nil")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
XCTAssertEqual(style.backgroundColor, .clear, "Default backgroundColor must be equal to nil")
XCTAssertEqual(style.backgroundColor, .clear, "Default backgroundColor must be equal to clear")

XCTAssertEqual(style.font, .systemFont(ofSize: 12), "Default style font must be equal to system font of 12 size")
XCTAssertEqual(style.color, .black, "Default color must be equal to nil")
XCTAssertEqual(style.backgroundColor, .clear, "Default backgroundColor must be equal to nil")
XCTAssertEqual(style.ligature, nil, "Default ligature must be equal to nil")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
XCTAssertEqual(style.ligature, nil, "Default ligature must be equal to nil")
XCTAssertNil(style.ligature, "Default ligature must be equal to nil")

Comment on lines 107 to 118
XCTAssertEqual(style.kerning, nil, "Default kerning must be equal to nil")
XCTAssertEqual(style.strokeWidth, nil, "Default strokeWidth must be equal to nil")
XCTAssertEqual(style.shadowStyle, nil, "Default shadowStyle must be equal to nil")
XCTAssertEqual(style.effectStyle, nil, "Default effectStyle must be equal to nil")
XCTAssertEqual(style.baselineOffset, nil, "Default baselineOffset must be equal to nil")
XCTAssertEqual(style.obliqueness, nil, "Default obliqueness must be equal to nil")
XCTAssertEqual(style.expansion, nil, "Default expansion must be equal to nil")
XCTAssertEqual(style.strikeThroughLine, nil, "Default strikeThroughLine must be equal to nil")
XCTAssertEqual(style.underlineLine, nil, "Default underlineLine must be equal to nil")
XCTAssertEqual(style.strokeColor, nil, "Default strokeColor must be equal to nil")
XCTAssertEqual(style.attachment, nil, "Default attachment must be equal to nil")
XCTAssertEqual(style.link, nil, "Default link must be equal to nil")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can also replace XCTAssertEqual to XCTAssertNil

Comment on lines 121 to 125
XCTAssertEqual(style.lineSpacing, nil, "Default lineSpacing must be equal to nil")
XCTAssertEqual(style.paragraphSpacing, nil, "Default paragraphSpacing must be equal to nil")
XCTAssertEqual(style.paragraphSpacingBefore, nil, "Default paragraphSpacingBefore must be equal to nil")
XCTAssertEqual(style.lineHeight, nil, "Default lineHeight must be equal to nil")
XCTAssertEqual(style.paragraphStyle, nil, "Default paragraphStyle must be equal to nil")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

//When
let copy = attributes.copy()
//Then
XCTAssertEqual(copy, attributes, "Copy is not equal to line attributes")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, this message contains a description what was wrong in this assertion

@artemnovichkov artemnovichkov merged commit 555b229 into master Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants