forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalAPITests.swift
More file actions
80 lines (68 loc) · 1.86 KB
/
GlobalAPITests.swift
File metadata and controls
80 lines (68 loc) · 1.86 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import XCTest
import JavaScriptKit
@_extern(wasm, module: "BridgeJSGlobalTests", name: "runJsWorksGlobal")
@_extern(c)
func runJsWorksGlobal() -> Void
// Minimal set of @JS declarations for testing globalThis access
// These are namespaced items that should be accessible via globalThis
@JS enum GlobalNetworking {
@JS enum API {
@JS enum CallMethod {
case get
case post
case put
case delete
}
@JS class TestHTTPServer {
@JS init() {}
@JS func call(_ method: CallMethod) {}
}
}
}
@JS enum GlobalConfiguration {
@JS enum PublicLogLevel: String {
case debug = "debug"
case info = "info"
case warning = "warning"
case error = "error"
}
@JS enum AvailablePort: Int {
case http = 80
case https = 443
case development = 3000
}
}
@JS(namespace: "GlobalNetworking.APIV2")
enum Internal {
@JS enum SupportedServerMethod {
case get
case post
}
@JS class TestInternalServer {
@JS init() {}
@JS func call(_ method: SupportedServerMethod) {}
}
}
@JS enum GlobalStaticPropertyNamespace {
@JS nonisolated(unsafe) static var namespaceProperty: String = "namespace"
@JS static let namespaceConstant: String = "constant"
@JS enum NestedProperties {
@JS nonisolated(unsafe) static var nestedProperty: Int = 999
@JS static let nestedConstant: String = "nested"
@JS nonisolated(unsafe) static var nestedDouble: Double = 1.414
}
}
@JS enum GlobalUtils {
@JS class PublicConverter {
@JS var precision: Int = 2
@JS init() {}
@JS func toString(value: Int) -> String {
return String(value)
}
}
}
class GlobalAPITests: XCTestCase {
func testGlobalAccess() {
runJsWorksGlobal()
}
}