Skip to content

Commit 2dfc69d

Browse files
yusufozgullukepistrol
authored andcommitted
Update unit tests
1 parent 0ebf841 commit 2dfc69d

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Tests/CodeEditTextViewTests/STTextViewControllerTests.swift

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class STTextViewControllerTests: XCTestCase {
3333
font: .monospacedSystemFont(ofSize: 11, weight: .medium),
3434
theme: theme,
3535
tabWidth: 4,
36-
overScrollLineCount: 5
36+
overScrollRatio: 0.5
3737
)
3838
}
3939

@@ -63,23 +63,32 @@ final class STTextViewControllerTests: XCTestCase {
6363

6464
func test_editorOverScroll() throws {
6565
let scrollView = try XCTUnwrap(controller.view as? NSScrollView)
66+
scrollView.frame = .init(x: .zero,
67+
y: .zero,
68+
width: 100,
69+
height: 100)
6670

67-
// overScrollLineCount: 5, lineHeight: 13
68-
XCTAssertEqual(scrollView.contentInsets.bottom, 65)
69-
}
70-
71+
// overScrollRatio: 0
72+
XCTAssertEqual(scrollView.contentView.contentInsets.bottom, 0)
7173

72-
func test_editorOverScroll_AfterUpdate() throws {
73-
let scrollView = try XCTUnwrap(controller.view as? NSScrollView)
74+
controller.overScrollRatio = 0.5
75+
controller.reloadUI()
7476

75-
// overScrollLineCount: 5, lineHeight: 13
76-
XCTAssertEqual(scrollView.contentInsets.bottom, 65)
77+
// overScrollRatio: 0.5
78+
XCTAssertEqual(scrollView.contentView.contentInsets.bottom, 50.0)
7779

78-
controller.overScrollLineCount = 10
80+
controller.overScrollRatio = 1.0
7981
controller.reloadUI()
8082

81-
// overScrollLineCount: 10, lineHeight: 13
82-
XCTAssertEqual(scrollView.contentInsets.bottom, 130)
83+
// overScrollRatio: 1.0
84+
XCTAssertEqual(scrollView.contentView.contentInsets.bottom, 87.0)
8385
}
8486

87+
func test_editorOverScroll_ZeroCondition() throws {
88+
let scrollView = try XCTUnwrap(controller.view as? NSScrollView)
89+
scrollView.frame = .zero
90+
91+
// overScrollRatio: 0
92+
XCTAssertEqual(scrollView.contentView.contentInsets.bottom, 0)
93+
}
8594
}

0 commit comments

Comments
 (0)