File tree Expand file tree Collapse file tree 1 file changed +38
-5
lines changed
swift/LiveViewNative/Tests/LiveViewNativeTests Expand file tree Collapse file tree 1 file changed +38
-5
lines changed Original file line number Diff line number Diff line change 1
1
import XCTest
2
2
@testable import LiveViewNative
3
3
4
+ class MyContext {
5
+ var didChange = false
6
+ }
7
+
4
8
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 )
10
43
}
11
44
}
You can’t perform that action at this time.
0 commit comments