Skip to content

Commit ef868f1

Browse files
committed
fix android tests run
1 parent b265762 commit ef868f1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

javascript/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ android {
1919
exclude("META-INF/AL2.0")
2020
exclude("META-INF/LGPL2.1")
2121
}
22+
23+
sourceSets {
24+
getByName("androidTest").java.srcDirs(
25+
file("src/androidAndroidTest/kotlin"),
26+
file("src/mobileDeviceTest/kotlin")
27+
)
28+
}
2229
}
2330

2431
kotlin {

javascript/src/androidMain/kotlin/dev/icerock/moko/javascript/JavaScriptEngine.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ actual class JavaScriptEngine actual constructor() {
4343
context: Map<String, JsType>,
4444
script: String
4545
): JsType {
46-
val scriptWithContext = convertContextMapToJsScript(context) + script
46+
val scriptWithContext = convertContextMapToJsScript(context) + script + "\n"
4747
val result = quickJs.evaluate(scriptWithContext)
4848
return handleQuickJsResult(result)
4949
}
@@ -63,10 +63,14 @@ actual class JavaScriptEngine actual constructor() {
6363
is JsType.DoubleNum -> valueWrapper.value.toString()
6464
is JsType.Json -> valueWrapper.value.let {
6565
Json.encodeToString(JsonElement.serializer(), it)
66+
}.let {
67+
it.replace("\"", "\\\"")
6668
}.let {
6769
"JSON.parse(\"$it\")"
6870
}
6971
is JsType.Str -> valueWrapper.value.let {
72+
it.replace("\"", "\\\"")
73+
}.let {
7074
"\"$it\""
7175
}
7276
JsType.Null -> null

0 commit comments

Comments
 (0)