-
Notifications
You must be signed in to change notification settings - Fork 381
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
Add extension of UIlabel for adding line spacing with the method of n… #438
base: master
Are you sure you want to change the base?
Changes from 2 commits
cd810e5
6a55e8f
f949239
d4b9474
2d20dac
d59ca01
c4d58e0
638c472
61f701b
e5f55c5
c00d920
277316f
fac501a
13b1dcc
f3047f8
e736d02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
// | ||
|
||
#if os(iOS) || os(tvOS) | ||
<<<<<<< HEAD | ||
======= | ||
|
||
import XCTest | ||
@testable import EZSwiftExtensions | ||
|
@@ -22,59 +24,67 @@ class UILabelTests: XCTestCase { | |
XCTAssertEqual(label2.font.pointSize, 20) | ||
XCTAssertEqual(label.font.pointSize, 17) | ||
} | ||
>>>>>>> 638c47200b16776d978dc4598237109396915878 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like an unresolved merge, please collapse your commits into one idempotent change. I cannot even begin to tell you how much I despise non fast forward merges. Rebase your changes and replay them on top of the current HEAD commit. |
||
|
||
func testSet() { | ||
import XCTest | ||
@testable import EZSwiftExtensions | ||
class UILabelTests: XCTestCase { | ||
|
||
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 50)) | ||
label.set(text: "EZSwiftExtensions✅", duration: 1) | ||
XCTAssertEqual(label.text, "EZSwiftExtensions✅") | ||
|
||
label.text = "" | ||
label.set(text: "EZSwiftExtensions🚀", duration: 0) | ||
XCTAssertEqual(label.text, "EZSwiftExtensions🚀") | ||
|
||
label.text = "" | ||
label.set(text: "EZSwiftExtensions❤️", duration: 1) | ||
XCTAssertEqual(label.text, "EZSwiftExtensions❤️") | ||
} | ||
|
||
func testSetLineSpacing(){ | ||
|
||
let textForTesting = "I am testing test Set line spacing method" | ||
var paragraphStyle : NSMutableParagraphStyle? | ||
func testInit() { | ||
|
||
let label = UILabel(x: 0, y: 0, w: 200, h: 50) | ||
let expected = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 50)) | ||
let label2 = UILabel(x: 0, y: 0, w: 200, h: 50, fontSize: 20) | ||
|
||
XCTAssertEqual(label.frame, expected.frame) | ||
XCTAssertEqual(label2.font.pointSize, 20) | ||
} | ||
|
||
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 50)) | ||
label.text = textForTesting | ||
label.setLineSpacing(lineSpacing: 1.5) | ||
func testSet() { | ||
|
||
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 50)) | ||
label.set(text: "EZSwiftExtensions✅", duration: 1) | ||
XCTAssertEqual(label.text, "EZSwiftExtensions✅") | ||
|
||
label.text = "" | ||
label.set(text: "EZSwiftExtensions🚀", duration: 0) | ||
XCTAssertEqual(label.text, "EZSwiftExtensions🚀") | ||
|
||
label.text = "" | ||
label.set(text: "EZSwiftExtensions❤️", duration: 1) | ||
XCTAssertEqual(label.text, "EZSwiftExtensions❤️") | ||
} | ||
|
||
label.attributedText?.enumerateAttribute(NSParagraphStyleAttributeName , in: NSMakeRange(0, (label.attributedText?.length)!), options: [.longestEffectiveRangeNotRequired]) { value, range, isStop in | ||
func testSetLineSpacing(){ | ||
|
||
let textForTesting = "I am testing test Set line spacing method" | ||
var paragraphStyle : NSMutableParagraphStyle? | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick : too many empty lines here are there that do not serve a purpose. |
||
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 50)) | ||
label.text = textForTesting | ||
label.setLineSpacing(lineSpacing: 1.5) | ||
|
||
if let value = value { | ||
|
||
paragraphStyle = value as! NSMutableParagraphStyle | ||
|
||
label.attributedText?.enumerateAttribute(NSParagraphStyleAttributeName , in: NSMakeRange(0, (label.attributedText?.length)!), options: [.longestEffectiveRangeNotRequired]) { value, range, isStop in | ||
if let value = value { | ||
paragraphStyle = value as NSMutableParagraphStyle | ||
} | ||
} | ||
|
||
XCTAssertEqual(paragraphStyle?.lineHeightMultiple, 1.5) | ||
} | ||
|
||
XCTAssertEqual(paragraphStyle?.lineHeightMultiple, 1.5) | ||
var waitExpectation: XCTestExpectation? | ||
|
||
|
||
func wait(duration: TimeInterval) { | ||
waitExpectation = expectation(description: "wait") | ||
Timer.scheduledTimer(timeInterval: duration, target: self, | ||
selector: #selector(UILabelTests.onTimer), userInfo: nil, repeats: false) | ||
waitForExpectations(timeout: duration + 3, handler: nil) | ||
} | ||
|
||
func onTimer() { | ||
waitExpectation?.fulfill() | ||
} | ||
} | ||
|
||
var waitExpectation: XCTestExpectation? | ||
|
||
func wait(duration: TimeInterval) { | ||
waitExpectation = expectation(description: "wait") | ||
Timer.scheduledTimer(timeInterval: duration, target: self, | ||
selector: #selector(UILabelTests.onTimer), userInfo: nil, repeats: false) | ||
waitForExpectations(timeout: duration + 3, handler: nil) | ||
} | ||
|
||
func onTimer() { | ||
waitExpectation?.fulfill() | ||
} | ||
} | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have unresolved merge commits here.