Skip to content

Commit 2d7d28e

Browse files
committed
added mainactor to image loader
1 parent 3327fb7 commit 2d7d28e

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

Sources/BuilderIO/Components/BuilderImageLoader.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ enum ImageStatus {
77
case error
88
}
99

10+
@MainActor
1011
@Observable
1112
class BuilderImageLoader {
1213

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
import XCTest
21
import BuilderIO
32
import SnapshotTesting
4-
import UIKit
53
import SwiftUI
4+
import UIKit
5+
import XCTest
66

77
@MainActor
88
class BuilderIOPageViewTests: XCTestCase {
9-
9+
1010
static let record = false
11-
11+
1212
override func setUpWithError() throws {
1313
BuilderIOManager.configure(apiKey: "UNITTESTINGAPIKEY", customNavigationScheme: "builderio")
14-
14+
1515
continueAfterFailure = false
1616
}
17-
17+
1818
override func tearDownWithError() throws {
1919
// Clear all mocks after each test
2020
print(" 🚨 Tests deregistered")
21-
21+
2222
BuilderIOMockManager.shared.clearAllMocks()
2323
try super.tearDownWithError()
2424
}
25-
26-
25+
2726
func testTextView() throws {
2827
BuilderIOMockManager.shared.registerMock(for: "/text", with: "text", statusCode: 200)
29-
28+
3029
let hostingController = makeHostingController(for: "/text", width: 375, height: 812)
31-
30+
3231
let expectation = XCTestExpectation(description: "Wait for view to render")
33-
32+
3433
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
35-
34+
3635
assertSnapshot(matching: hostingController, as: .image, record: BuilderIOPageViewTests.record)
3736
expectation.fulfill()
3837
}
39-
40-
38+
4139
wait(for: [expectation], timeout: 3)
4240
}
43-
41+
4442
func testLayoutsView() throws {
4543
BuilderIOMockManager.shared.registerMock(for: "/layout", with: "layout", statusCode: 200)
46-
44+
4745
let hostingController = makeHostingController(for: "/layout", width: 375, height: 812)
48-
46+
4947
let expectation = XCTestExpectation(description: "Wait for view to render")
50-
48+
5149
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
52-
50+
5351
assertSnapshot(matching: hostingController, as: .image, record: BuilderIOPageViewTests.record)
5452
expectation.fulfill()
5553
}
56-
57-
54+
5855
wait(for: [expectation], timeout: 3)
5956
}
60-
57+
6158
/// - Returns: A UIHostingController wrapping the SwiftUI Text view.
62-
func makeHostingController(for url: String, width: CGFloat, height: CGFloat) -> UIHostingController<some View> {
63-
let view = BuilderIOPage(url: url, onClickEventHandler: { event in
64-
print("Handle Event Action")
65-
})
66-
59+
func makeHostingController(for url: String, width: CGFloat, height: CGFloat)
60+
-> UIHostingController<some View>
61+
{
62+
let view = BuilderIOPage(
63+
url: url,
64+
onClickEventHandler: { event in
65+
print("Handle Event Action")
66+
})
67+
6768
let hostingController = UIHostingController(rootView: view.frame(width: 375, height: 812))
6869
hostingController.view.frame = CGRect(x: 0, y: 0, width: 375, height: 812)
69-
70+
7071
let window = UIWindow(frame: hostingController.view.frame)
7172
window.rootViewController = hostingController
7273
window.makeKeyAndVisible()
73-
74-
74+
7575
return hostingController
7676
}
7777
}

0 commit comments

Comments
 (0)