Skip to content

Commit 62ab681

Browse files
committed
Fix tests
1 parent 8d6df6c commit 62ab681

File tree

1 file changed

+10
-38
lines changed

1 file changed

+10
-38
lines changed
Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,19 @@
1-
import Foundation
21
import Testing
32
import WebKit
43
@testable import GutenbergKit
54

6-
@Suite("GBWebView Tests")
75
struct GBWebViewTests {
8-
9-
@Test("Application name for user agent is set correctly")
6+
7+
@MainActor
108
func testApplicationNameForUserAgent() async throws {
11-
// Given
12-
let webView = GBWebView()
13-
14-
// When
15-
webView.applicationNameForUserAgent = "GutenbergKit/\(GBKVersion.version)"
16-
17-
// Then
18-
#expect(webView.applicationNameForUserAgent == "GutenbergKit/\(GBKVersion.version)")
19-
}
20-
21-
@Test("Version constant exists and is valid")
22-
func testVersionConstantExists() async throws {
23-
// Then
24-
#expect(!GBKVersion.version.isEmpty)
25-
#expect(GBKVersion.version.contains("."))
9+
let result = try await GBWebView().evaluateJavaScript("navigator.userAgent")
10+
let string = try #require(result as? String)
11+
12+
#expect(string.hasSuffix("GutenbergKit/\(GBKVersion.version)"))
2613
}
27-
28-
@Test("Navigator user agent includes GutenbergKit identifier")
29-
func testNavigatorUserAgentIncludesGutenbergKit() async throws {
30-
// Given
31-
let webView = GBWebView()
32-
webView.applicationNameForUserAgent = "GutenbergKit/\(GBKVersion.version)"
33-
34-
// Load a simple HTML page to ensure the WebView is ready
35-
let html = "<html><body>Test</body></html>"
36-
webView.loadHTMLString(html, baseURL: nil)
37-
38-
// Wait for the page to load
39-
try await Task.sleep(for: .milliseconds(500))
40-
41-
// When - evaluate navigator.userAgent in the WebView
42-
let userAgent = try await webView.evaluateJavaScript("navigator.userAgent") as? String
43-
44-
// Then
45-
#expect(userAgent?.contains("GutenbergKit/\(GBKVersion.version)") == true)
14+
15+
func testVersionConstantExists() {
16+
#expect(GBKVersion.version.isEmpty, "Version constant should not be empty")
17+
#expect(GBKVersion.version.contains("."), "Version should be in semantic versioning format")
4618
}
4719
}

0 commit comments

Comments
 (0)