Skip to content

Commit a250ab3

Browse files
committed
Bring back fetchWeatherData
1 parent ae831f1 commit a250ab3

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Tests/BridgeJSRuntimeTests/AsyncImportTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import JavaScriptKit
1212
@JSFunction static func jsAsyncRoundTripIntArray(_ values: [Double]) async throws(JSException) -> [Double]
1313
@JSFunction static func jsAsyncRoundTripStringArray(_ values: [String]) async throws(JSException) -> [String]
1414
@JSFunction static func jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async throws(JSException) -> FeatureFlag
15-
@JSFunction static func fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData
1615
}
1716

1817
@Suite struct AsyncImportTests {
@@ -73,12 +72,12 @@ import JavaScriptKit
7372
// MARK: - Structured return type
7473

7574
@Test func fetchWeatherData() async throws {
76-
let weather = try await AsyncImportImports.fetchWeatherData("London")
75+
let weather = try await BridgeJSRuntimeTests.fetchWeatherData("London")
7776
#expect(try weather.temperature == 15.5)
7877
#expect(try weather.description == "Cloudy")
7978
#expect(try weather.humidity == 80)
8079

81-
let weather2 = try await AsyncImportImports.fetchWeatherData("Tokyo")
80+
let weather2 = try await BridgeJSRuntimeTests.fetchWeatherData("Tokyo")
8281
#expect(try weather2.temperature == 25.0)
8382
#expect(try weather2.description == "Sunny")
8483
#expect(try weather2.humidity == 40)

Tests/BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ export function getImports(importsContext) {
3737
jsAsyncRoundTripFeatureFlag: (v) => {
3838
return Promise.resolve(v);
3939
},
40-
fetchWeatherData: (city) => {
41-
return Promise.resolve({
42-
temperature: city === "London" ? 15.5 : 25.0,
43-
description: city === "London" ? "Cloudy" : "Sunny",
44-
humidity: city === "London" ? 80 : 40,
45-
});
46-
},
4740
};
4841
}
4942

Tests/prelude.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ export async function setupOptions(options, context) {
129129
return;
130130
},
131131
AsyncImportImports: getAsyncImportImports(importsContext),
132+
fetchWeatherData: (city) => {
133+
return Promise.resolve({
134+
temperature: city === "London" ? 15.5 : 25.0,
135+
description: city === "London" ? "Cloudy" : "Sunny",
136+
humidity: city === "London" ? 80 : 40,
137+
});
138+
},
132139
jsTranslatePoint: (point, dx, dy) => {
133140
return { x: (point.x | 0) + (dx | 0), y: (point.y | 0) + (dy | 0) };
134141
},

0 commit comments

Comments
 (0)