forked from CodeEditApp/CodeEditSourceEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeSitterClientTests.swift
More file actions
46 lines (37 loc) · 1.3 KB
/
Copy pathTreeSitterClientTests.swift
File metadata and controls
46 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import XCTest
import CodeEditTextView
@testable import CodeEditSourceEditor
// swiftlint:disable all
final class TreeSitterClientTests: XCTestCase {
class Delegate: TextViewDelegate { }
fileprivate var textView = TextView(
string: "func testSwiftFunc() -> Int {\n\tprint(\"\")\n}",
font: .monospacedSystemFont(ofSize: 12, weight: .regular),
textColor: .labelColor,
lineHeightMultiplier: 1.0,
wrapLines: true,
isEditable: true,
isSelectable: true,
letterSpacing: 1.0,
delegate: Delegate()
)
var client: TreeSitterClient!
override func setUp() {
client = TreeSitterClient()
}
func test_clientSetup() {
client.setUp(textView: textView, codeLanguage: .swift)
let now = Date()
while client.state == nil && abs(now.timeIntervalSinceNow) < 5 {
usleep(1000)
}
if abs(now.timeIntervalSinceNow) >= 5 {
XCTFail("Client took more than 5 seconds to set up.")
}
let primaryLanguage = client.state?.primaryLayer.id
let layerCount = client.state?.layers.count
XCTAssertEqual(primaryLanguage, .swift, "Client set up incorrect language")
XCTAssertEqual(layerCount, 1, "Client set up too many layers")
}
}
// swiftlint:enable all