Skip to content

Commit 6346b78

Browse files
committed
test(swift): add a simple integration test for the bindings
1 parent b1501b9 commit 6346b78

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed
Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
11
import XCTest
22
@testable import LiveViewNative
33

4+
class MyContext {
5+
var didChange = false
6+
}
7+
48
final class LiveViewNativeTests: XCTestCase {
5-
func testExample() throws {
6-
// This is an example of a functional test case.
7-
// Use XCTAssert and related functions to verify your tests produce the correct
8-
// results.
9-
//XCTAssertEqual(LiveViewNative().text, "Hello, World!")
9+
func testIntegration() throws {
10+
let context = MyContext()
11+
let input = """
12+
<html lang="en">
13+
<head>
14+
<meta charset="utf-8" />
15+
</head>
16+
<body class="new-value" class="main">
17+
some content
18+
</body>
19+
</html>
20+
"""
21+
let doc1 = try Document.parse(input)
22+
doc1.on(.changed, with: context) { doc, ctx in
23+
XCTAssertEqual(ctx is MyContext, true)
24+
(ctx as! MyContext).didChange = true
25+
}
26+
27+
let updated = """
28+
<html lang="en">
29+
<head>
30+
<meta charset="utf-8" />
31+
<meta name="title" content="Hello World" />
32+
</head>
33+
<body class="new-value" class="main">
34+
new content
35+
</body>
36+
</html>
37+
"""
38+
let doc2 = try Document.parse(updated)
39+
40+
doc1.merge(with: doc2)
41+
42+
XCTAssertEqual(context.didChange, true)
1043
}
1144
}

0 commit comments

Comments
 (0)