@momo-kits/native-kits 0.169.13-beta.4-debug → 0.169.13-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -4
- package/compose/build.gradle.kts +1 -5
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +12 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +11 -3
- package/gradle/libs.versions.toml +0 -2
- package/gradle.properties +1 -1
- package/ios/Navigation/BottomTab/BottomTabBar.swift +14 -4
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +16 -3
- package/package.json +1 -1
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +0 -647
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +0 -1411
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +0 -130
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +0 -524
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +0 -559
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +0 -741
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +0 -221
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +0 -270
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +0 -849
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +0 -212
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +0 -239
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +0 -252
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +0 -154
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +0 -1038
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +0 -848
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +0 -47
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +0 -463
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +0 -1146
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +0 -667
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +0 -240
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +0 -200
- package/scripts/sdui-visual/README.md +0 -64
- package/scripts/sdui-visual/diff.py +0 -65
- package/scripts/sdui-visual/drive.py +0 -234
- package/scripts/sdui-visual/plan.json +0 -713
- package/scripts/sdui-visual/run.sh +0 -92
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
// File: compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt
|
|
2
|
-
// Created At: 2026-11-03 12:00:00 +07:00
|
|
3
|
-
// Created By: AI
|
|
4
|
-
// AI Agent: Claude Code
|
|
5
|
-
// Model: claude-sonnet-5-5
|
|
6
|
-
|
|
7
|
-
package vn.momo.kits.sdui
|
|
8
|
-
|
|
9
|
-
import androidx.compose.runtime.mutableStateMapOf
|
|
10
|
-
import org.junit.Assert.assertEquals
|
|
11
|
-
import org.junit.Assert.assertNull
|
|
12
|
-
import org.junit.Assert.assertSame
|
|
13
|
-
import org.junit.Assert.assertTrue
|
|
14
|
-
import org.junit.Test
|
|
15
|
-
import vn.momo.kits.const.defaultTheme
|
|
16
|
-
import vn.momo.maxapi.IMaxApi
|
|
17
|
-
import java.lang.reflect.Proxy
|
|
18
|
-
|
|
19
|
-
/** A recording IMaxApi: [onCall] gets every call's method name and its args. */
|
|
20
|
-
internal fun fakeMaxApi(onCall: (String, List<Any?>) -> Unit): IMaxApi =
|
|
21
|
-
Proxy.newProxyInstance(IMaxApi::class.java.classLoader, arrayOf(IMaxApi::class.java)) { _, m, args ->
|
|
22
|
-
onCall(m.name, args?.toList().orEmpty())
|
|
23
|
-
when (m.returnType) { Boolean::class.javaPrimitiveType -> false; Int::class.javaPrimitiveType -> 0; Long::class.javaPrimitiveType -> 0L; Map::class.java -> emptyMap<String, Any?>(); else -> null }
|
|
24
|
-
} as IMaxApi
|
|
25
|
-
|
|
26
|
-
/** An SduiLog whose logFile lines land in [lines]. */
|
|
27
|
-
internal fun capturingLog(lines: MutableList<String>, label: String = "t"): SduiLog =
|
|
28
|
-
SduiLog(SduiMaxApi({ fakeMaxApi { name, args -> if (name == "logFile") lines += ((args[0] as? Array<*>)?.firstOrNull() ?: args[0]).toString() } }), label)
|
|
29
|
-
|
|
30
|
-
// AI-GENERATED START: unit tests for the per-view error sink (logFile), MaxApi isolation between views
|
|
31
|
-
class SduiHostTest {
|
|
32
|
-
/** A recording IMaxApi: every call lands in [calls] as `method:args`. */
|
|
33
|
-
private class FakeApi() {
|
|
34
|
-
val calls = ArrayList<String>()
|
|
35
|
-
val api: IMaxApi = Proxy.newProxyInstance(IMaxApi::class.java.classLoader, arrayOf(IMaxApi::class.java)) { _, m, args ->
|
|
36
|
-
calls += m.name + ":" + (args?.filter { it !is Function<*> }?.joinToString(",") { if (it is Array<*>) it.toList().toString() else it.toString() } ?: "")
|
|
37
|
-
when {
|
|
38
|
-
m.returnType == Boolean::class.javaPrimitiveType -> false
|
|
39
|
-
m.returnType == Int::class.javaPrimitiveType -> 0
|
|
40
|
-
m.returnType == Long::class.javaPrimitiveType -> 0L
|
|
41
|
-
m.returnType == Map::class.java -> emptyMap<String, Any?>()
|
|
42
|
-
else -> null
|
|
43
|
-
}
|
|
44
|
-
} as IMaxApi
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// ---- error sink -----------------------------------------------------------------------------------------------
|
|
48
|
-
private fun logOf(api: IMaxApi?, label: String = "block") = SduiLog(SduiMaxApi({ api }), label)
|
|
49
|
-
|
|
50
|
-
@Test fun logWritesLabelledLineThroughLogFile() {
|
|
51
|
-
val f = FakeApi(); logOf(f.api, "ins_card").w("expr failed: a +")
|
|
52
|
-
assertEquals(listOf("logFile:[[SDUI] ins_card: expr failed: a +]"), f.calls)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@Test fun sameMessageIsWrittenOncePerInstance() {
|
|
56
|
-
val f = FakeApi(); val log = logOf(f.api)
|
|
57
|
-
repeat(3) { log.w("same") }
|
|
58
|
-
assertEquals(1, f.calls.size)
|
|
59
|
-
logOf(f.api).w("same"); assertEquals(2, f.calls.size) // a new instance (new view) starts fresh
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@Test fun distinctLinesAreCapped() {
|
|
63
|
-
val f = FakeApi(); val log = logOf(f.api)
|
|
64
|
-
repeat(SduiLog.MAX_LINES + 30) { log.w("line $it") }
|
|
65
|
-
assertEquals(SduiLog.MAX_LINES, f.calls.size)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@Test fun logWithoutApiIsSilent() { SduiLog.NONE.w("dropped"); logOf(null).w("dropped"); SduiMaxApi.NONE.logFile("dropped") }
|
|
69
|
-
|
|
70
|
-
@Test fun logSwallowsApiFailures() {
|
|
71
|
-
val boom = Proxy.newProxyInstance(IMaxApi::class.java.classLoader, arrayOf(IMaxApi::class.java)) { _, _, _ -> error("boom") } as IMaxApi
|
|
72
|
-
logOf(boom).w("x")
|
|
73
|
-
SduiMaxApi({ boom }).apply { track("e", emptyMap()); logFile("x"); startFeatureCode("f", emptyMap()) }
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@Test fun twoViewsLogToTheirOwnApi() {
|
|
77
|
-
val a = FakeApi(); val b = FakeApi()
|
|
78
|
-
val sa = SduiScope(emptyMap(), emptyMap(), log = logOf(a.api, "A")); val sb = SduiScope(emptyMap(), emptyMap(), log = logOf(b.api, "B"))
|
|
79
|
-
evalExpr("1 +", sa); evalExpr("2 *", sb)
|
|
80
|
-
assertEquals(1, a.calls.size); assertEquals(1, b.calls.size)
|
|
81
|
-
assertTrue(a.calls[0].contains("A: expr failed: 1 +")); assertTrue(b.calls[0].contains("B: expr failed: 2 *"))
|
|
82
|
-
resolveToken("Spacing.Nope", defaultTheme, logOf(a.api, "A"))
|
|
83
|
-
assertTrue(a.calls.last().contains("unknown token Spacing.Nope")); assertEquals(1, b.calls.size)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Test fun anUnknownTokenProducedByABindingIsNotLogged() {
|
|
87
|
-
val f = FakeApi()
|
|
88
|
-
val sc = SduiScope(mapOf("c" to "Colors.SECRET"), emptyMap(), log = logOf(f.api))
|
|
89
|
-
resolveValue(mapOf("a" to "{c}", "b" to "Spacing.Nope"), sc, defaultTheme)
|
|
90
|
-
assertTrue(f.calls.none { "SECRET" in it })
|
|
91
|
-
assertTrue(f.calls.any { "unknown token (from binding)" in it }); assertTrue(f.calls.any { "unknown token Spacing.Nope" in it })
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@Test fun exprFailureLineCarriesExpressionButNotTheExceptionMessage() {
|
|
95
|
-
val f = FakeApi()
|
|
96
|
-
evalExpr("1 +", SduiScope(emptyMap(), emptyMap(), log = logOf(f.api)))
|
|
97
|
-
assertEquals("logFile:[[SDUI] block: expr failed: 1 +]", f.calls.single())
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ---- MaxApi isolation -----------------------------------------------------------------------------------------
|
|
101
|
-
private fun runner(api: FakeApi?, log: SduiLog = SduiLog.NONE): SduiActionRunner {
|
|
102
|
-
val maxApi = SduiMaxApi({ api?.api })
|
|
103
|
-
return SduiActionRunner(mutableStateMapOf(), { defaultTheme }, maxApi = maxApi, log = log)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@Test fun twoViewsRouteActionsToTheirOwnApi() {
|
|
107
|
-
val a = FakeApi(); val b = FakeApi()
|
|
108
|
-
val ra = runner(a); val rb = runner(b)
|
|
109
|
-
val feature = mapOf("name" to "onPress", "type" to "startFeatureCode", "params" to mapOf("featureCode" to "fa"))
|
|
110
|
-
ra.runOne(feature, SduiScope(emptyMap(), emptyMap()), emptyList())
|
|
111
|
-
rb.runOne(feature + ("params" to mapOf("featureCode" to "fb")), SduiScope(emptyMap(), emptyMap()), emptyList())
|
|
112
|
-
assertEquals(listOf("startFeatureCode:[fa, {}]"), a.calls)
|
|
113
|
-
assertEquals(listOf("startFeatureCode:[fb, {}]"), b.calls)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@Test fun aViewWithoutApiDoesNotAffectOthers() {
|
|
117
|
-
val a = FakeApi()
|
|
118
|
-
val ra = runner(a); val rn = runner(null, logOf(null))
|
|
119
|
-
rn.runOne(mapOf("name" to "x", "type" to "startFeatureCode", "params" to mapOf("featureCode" to "f")), SduiScope(emptyMap(), emptyMap()), emptyList())
|
|
120
|
-
assertTrue(a.calls.isEmpty()) // untouched by the api-less view
|
|
121
|
-
ra.runOne(mapOf("name" to "x", "type" to "startFeatureCode", "params" to mapOf("featureCode" to "g")), SduiScope(emptyMap(), emptyMap()), emptyList())
|
|
122
|
-
assertEquals(listOf("startFeatureCode:[g, {}]"), a.calls)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Test fun apiResolutionOrderIsParamThenKitLocal() { // M4
|
|
126
|
-
val p = FakeApi().api; val k = FakeApi().api
|
|
127
|
-
assertSame(p, pickMaxApi(p, k)); assertSame(k, pickMaxApi(null, k)); assertNull(pickMaxApi(null, null))
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
// AI-GENERATED END: unit tests for the per-view host seams
|
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
// File: compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt
|
|
2
|
-
// Created At: 2026-11-10 11:00:00 +07:00
|
|
3
|
-
// Created By: AI
|
|
4
|
-
// AI Agent: Claude Code
|
|
5
|
-
// Model: claude-sonnet-5-5
|
|
6
|
-
|
|
7
|
-
package vn.momo.kits.sdui
|
|
8
|
-
|
|
9
|
-
import androidx.compose.ui.graphics.Color
|
|
10
|
-
import androidx.compose.ui.text.input.KeyboardType
|
|
11
|
-
import androidx.compose.ui.unit.dp
|
|
12
|
-
import org.junit.Assert.assertArrayEquals
|
|
13
|
-
import org.junit.Assert.assertEquals
|
|
14
|
-
import org.junit.Assert.assertFalse
|
|
15
|
-
import org.junit.Assert.assertNotNull
|
|
16
|
-
import org.junit.Assert.assertNull
|
|
17
|
-
import org.junit.Assert.assertTrue
|
|
18
|
-
import org.junit.Test
|
|
19
|
-
import vn.momo.kits.components.AvatarSize
|
|
20
|
-
import vn.momo.kits.components.ButtonType
|
|
21
|
-
import vn.momo.kits.components.CollapseTitleSize
|
|
22
|
-
import vn.momo.kits.components.DividerType
|
|
23
|
-
import vn.momo.kits.components.IconShape
|
|
24
|
-
import vn.momo.kits.components.IconSize
|
|
25
|
-
import vn.momo.kits.components.InformationState
|
|
26
|
-
import vn.momo.kits.components.InputFontWeight
|
|
27
|
-
import vn.momo.kits.components.InputPhoneNumberSize
|
|
28
|
-
import vn.momo.kits.components.InputSize
|
|
29
|
-
import vn.momo.kits.components.LoaderType
|
|
30
|
-
import vn.momo.kits.components.PopupActionDirection
|
|
31
|
-
import vn.momo.kits.components.RatingSize
|
|
32
|
-
import vn.momo.kits.components.StepItem
|
|
33
|
-
import vn.momo.kits.components.StepperSize
|
|
34
|
-
import vn.momo.kits.components.StepsAlign
|
|
35
|
-
import vn.momo.kits.components.TagColor
|
|
36
|
-
import vn.momo.kits.components.UploadImage
|
|
37
|
-
|
|
38
|
-
// AI-GENERATED START: unit tests for the per-node args (props -> kit parameters, callbacks -> fired action name + arguments)
|
|
39
|
-
class SduiKitArgsTest {
|
|
40
|
-
private val fires = mutableListOf<Pair<String, List<Any?>>>()
|
|
41
|
-
private val fire: Fire = { n, a -> fires += n to a }
|
|
42
|
-
private val none = { _: String -> false }
|
|
43
|
-
private val all = { _: String -> true }
|
|
44
|
-
private val hint = Color(0xFF111111)
|
|
45
|
-
private val dflt = Color(0xFF222222)
|
|
46
|
-
|
|
47
|
-
private fun assertFired(name: String, vararg args: Any?) {
|
|
48
|
-
assertEquals(listOf(name to args.toList()), fires)
|
|
49
|
-
fires.clear()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// ---- Avatar
|
|
53
|
-
@Test fun avatarDefaults() {
|
|
54
|
-
val a = avatarArgsOf(emptyMap())
|
|
55
|
-
assertEquals(AvatarSize.SIZE_32, a.size); assertTrue(a.rounded); assertNull(a.name); assertNull(a.image)
|
|
56
|
-
assertFalse(a.showIconMomo); assertFalse(a.showIconSupport)
|
|
57
|
-
assertEquals(AVATAR_ICON_SUPPORT_DEFAULT, a.iconSupport); assertNull(a.accessibilityLabel)
|
|
58
|
-
}
|
|
59
|
-
@Test fun avatarProps() {
|
|
60
|
-
val a = avatarArgsOf(mapOf("size" to 48, "rounded" to false, "name" to "An", "image" to "u", "showIconMomo" to true,
|
|
61
|
-
"showIconSupport" to true, "iconSupport" to "i", "accessibilityLabel" to "acc"))
|
|
62
|
-
assertEquals(AvatarSize.SIZE_48, a.size); assertFalse(a.rounded); assertEquals("An", a.name); assertEquals("u", a.image)
|
|
63
|
-
assertTrue(a.showIconMomo); assertTrue(a.showIconSupport); assertEquals("i", a.iconSupport); assertEquals("acc", a.accessibilityLabel)
|
|
64
|
-
}
|
|
65
|
-
@Test fun avatarEmptyIconSupportStaysEmpty() = assertEquals("", avatarArgsOf(mapOf("iconSupport" to "")).iconSupport)
|
|
66
|
-
|
|
67
|
-
// ---- CheckBox
|
|
68
|
-
@Test fun checkBoxDefaults() {
|
|
69
|
-
val a = checkBoxArgsOf(emptyMap(), fire)
|
|
70
|
-
assertFalse(a.disabled); assertFalse(a.checked); assertFalse(a.indeterminate); assertEquals("", a.title)
|
|
71
|
-
}
|
|
72
|
-
@Test fun checkBoxPropsAndCallback() {
|
|
73
|
-
val a = checkBoxArgsOf(mapOf("disabled" to true, "value" to true, "indeterminate" to true, "label" to "L"), fire)
|
|
74
|
-
assertTrue(a.disabled); assertTrue(a.checked); assertTrue(a.indeterminate); assertEquals("L", a.title)
|
|
75
|
-
a.onCheckedChange(true); assertFired("onChange", true)
|
|
76
|
-
a.onCheckedChange(false); assertFired("onChange", false)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ---- Switch
|
|
80
|
-
@Test fun switchDefaults() {
|
|
81
|
-
val a = switchArgsOf(emptyMap(), fire)
|
|
82
|
-
assertFalse(a.value); assertFalse(a.disabled); assertEquals("", a.title); assertNull(a.accessibilityId)
|
|
83
|
-
}
|
|
84
|
-
@Test fun switchLabelBeatsTitle() {
|
|
85
|
-
assertEquals("L", switchArgsOf(mapOf("label" to "L", "title" to "T"), fire).title)
|
|
86
|
-
assertEquals("T", switchArgsOf(mapOf("title" to "T"), fire).title)
|
|
87
|
-
}
|
|
88
|
-
@Test fun switchPropsAndCallback() {
|
|
89
|
-
val a = switchArgsOf(mapOf("value" to true, "disabled" to true, "accessibilityLabel" to "acc"), fire)
|
|
90
|
-
assertTrue(a.value); assertTrue(a.disabled); assertEquals("acc", a.accessibilityId)
|
|
91
|
-
a.onChange(true); assertFired("onChange", true)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// ---- Radio
|
|
95
|
-
@Test fun radioDefaults() {
|
|
96
|
-
val a = radioArgsOf(emptyMap(), fire)
|
|
97
|
-
assertEquals("", a.value); assertEquals("", a.groupValue); assertFalse(a.disabled); assertEquals("", a.label)
|
|
98
|
-
}
|
|
99
|
-
@Test fun radioPropsAndCallback() {
|
|
100
|
-
val a = radioArgsOf(mapOf("value" to 1, "groupValue" to "g", "disabled" to true, "label" to "L"), fire)
|
|
101
|
-
assertEquals(1, a.value); assertEquals("g", a.groupValue); assertTrue(a.disabled); assertEquals("L", a.label)
|
|
102
|
-
a.onChange(); assertFired("onChange")
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ---- Divider / Loader
|
|
106
|
-
@Test fun dividerDefaultsAndProps() {
|
|
107
|
-
val d = dividerArgsOf(emptyMap()); assertFalse(d.useMargin); assertEquals(DividerType.DEFAULT, d.type)
|
|
108
|
-
val e = dividerArgsOf(mapOf("useMargin" to true, "type" to "dash")); assertTrue(e.useMargin); assertEquals(DividerType.DASH, e.type)
|
|
109
|
-
}
|
|
110
|
-
@Test fun loaderDefaultsAndProps() {
|
|
111
|
-
val d = loaderArgsOf(emptyMap()); assertEquals(LoaderType.DOT, d.type); assertNull(d.tintColor)
|
|
112
|
-
val e = loaderArgsOf(mapOf("type" to "spinner", "color" to "#ff0000")); assertEquals(LoaderType.SPINNER, e.type)
|
|
113
|
-
assertEquals(Color(0xFFFF0000), e.tintColor)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// ---- IconButton
|
|
117
|
-
@Test fun iconButtonDefaults() {
|
|
118
|
-
val a = iconButtonArgsOf(emptyMap(), fire)
|
|
119
|
-
assertEquals(ButtonType.PRIMARY, a.type); assertEquals(IconSize.SMALL, a.size); assertEquals(IconShape.CIRCLE, a.shape); assertEquals("", a.icon)
|
|
120
|
-
}
|
|
121
|
-
@Test fun iconButtonPropsAndCallback() {
|
|
122
|
-
val a = iconButtonArgsOf(mapOf("type" to "danger", "size" to "large", "shape" to "square", "icon" to "ic"), fire)
|
|
123
|
-
assertEquals(ButtonType.DANGER, a.type); assertEquals(IconSize.LARGE, a.size); assertEquals(IconShape.SQUARE, a.shape); assertEquals("ic", a.icon)
|
|
124
|
-
a.onClick(); assertFired("onPress")
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ---- Information
|
|
128
|
-
@Test fun informationDefaults() {
|
|
129
|
-
val a = informationArgsOf(emptyMap(), none, fire)
|
|
130
|
-
assertNull(a.title); assertEquals("Description", a.description); assertEquals(InformationState.DEFAULT, a.state); assertNull(a.image)
|
|
131
|
-
assertNull(a.onPressAction); assertTrue(a.showIcon); assertNull(a.action); assertTrue(a.showIconClose); assertNull(a.onPressClose)
|
|
132
|
-
assertNull(a.accessibilityLabel); assertEquals(emptyList<String>(), a.highlightText)
|
|
133
|
-
}
|
|
134
|
-
@Test fun informationProps() {
|
|
135
|
-
val a = informationArgsOf(mapOf("title" to "T", "description" to "D", "state" to "warning", "image" to "i", "showIcon" to false,
|
|
136
|
-
"CTA" to "Go", "showIconClose" to false, "accessibilityLabel" to "acc", "highlightText" to listOf("a", 2)), none, fire)
|
|
137
|
-
assertEquals("T", a.title); assertEquals("D", a.description); assertEquals(InformationState.WARNING, a.state); assertEquals("i", a.image)
|
|
138
|
-
assertFalse(a.showIcon); assertEquals("Go", a.action); assertFalse(a.showIconClose); assertEquals("acc", a.accessibilityLabel)
|
|
139
|
-
assertEquals(listOf("a", "2"), a.highlightText)
|
|
140
|
-
}
|
|
141
|
-
@Test fun informationCallbacksOnlyWhenDeclared() {
|
|
142
|
-
val onlyCta = informationArgsOf(emptyMap(), { it == "onPressCTA" }, fire)
|
|
143
|
-
assertNotNull(onlyCta.onPressAction); assertNull(onlyCta.onPressClose)
|
|
144
|
-
onlyCta.onPressAction!!(); assertFired("onPressCTA")
|
|
145
|
-
val onlyClose = informationArgsOf(emptyMap(), { it == "onPressClose" }, fire)
|
|
146
|
-
assertNull(onlyClose.onPressAction); onlyClose.onPressClose!!(); assertFired("onPressClose")
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// ---- Input
|
|
150
|
-
@Test fun inputDefaults() {
|
|
151
|
-
val a = inputArgsOf(emptyMap(), fire, hint, dflt)
|
|
152
|
-
assertEquals("", a.floatingValue); assertEquals("", a.placeholder); assertEquals(InputSize.SMALL, a.size); assertEquals("", a.error)
|
|
153
|
-
assertFalse(a.readOnly); assertFalse(a.secureTextEntry); assertNull(a.maxLength); assertEquals(KeyboardType.Text, a.keyboardType)
|
|
154
|
-
assertEquals(hint, a.floatingValueColor); assertEquals(dflt, a.floatingIconColor); assertEquals(dflt, a.iconColor)
|
|
155
|
-
assertEquals(hint, a.leadingIconColor); assertEquals(InputFontWeight.REGULAR, a.fontWeight)
|
|
156
|
-
}
|
|
157
|
-
@Test fun inputProps() {
|
|
158
|
-
val red = Color(0xFFFF0000)
|
|
159
|
-
val a = inputArgsOf(mapOf("floatingValue" to "fv", "floatingIcon" to "fi", "placeholder" to "ph", "size" to "large", "hintText" to "h",
|
|
160
|
-
"errorMessage" to "e", "errorSpacing" to true, "disabled" to true, "editable" to false, "secureTextEntry" to true, "trailing" to "tr",
|
|
161
|
-
"leadingIcon" to "li", "loading" to true, "required" to true, "maxLength" to 8, "keyboardType" to "email-address",
|
|
162
|
-
"floatingValueColor" to "#ff0000", "fontWeight" to "bold"), fire, hint, dflt)
|
|
163
|
-
assertEquals("fv", a.floatingValue); assertEquals("fi", a.floatingIcon); assertEquals("ph", a.placeholder); assertEquals(InputSize.LARGE, a.size)
|
|
164
|
-
assertEquals("h", a.hintText); assertEquals("e", a.error); assertTrue(a.errorSpacing); assertTrue(a.disabled); assertTrue(a.readOnly)
|
|
165
|
-
assertTrue(a.secureTextEntry); assertEquals("tr", a.icon); assertEquals("li", a.leadingIcon); assertTrue(a.loading); assertTrue(a.required)
|
|
166
|
-
assertEquals(8, a.maxLength); assertEquals(KeyboardType.Email, a.keyboardType); assertEquals(red, a.floatingValueColor)
|
|
167
|
-
assertEquals(InputFontWeight.BOLD, a.fontWeight)
|
|
168
|
-
}
|
|
169
|
-
@Test fun inputCallbacks() {
|
|
170
|
-
val a = inputArgsOf(emptyMap(), fire, hint, dflt)
|
|
171
|
-
a.onChangeText("x"); assertFired("onChangeText", "x")
|
|
172
|
-
a.onRightIconPressed(); assertFired("onPressTrailing")
|
|
173
|
-
a.onFocus(); assertFired("onFocus")
|
|
174
|
-
a.onBlur(); assertFired("onBlur")
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// ---- InputDropDown
|
|
178
|
-
@Test fun inputDropDownDefaults() {
|
|
179
|
-
val a = inputDropDownArgsOf(emptyMap(), fire, hint, dflt)
|
|
180
|
-
assertEquals("arrow_chevron_down_small", a.icon); assertEquals(InputSize.SMALL, a.size); assertEquals("", a.leadingIcon)
|
|
181
|
-
assertEquals(hint, a.floatingValueColor); assertEquals(dflt, a.floatingIconColor); assertEquals(dflt, a.iconColor); assertEquals(hint, a.leadingIconColor)
|
|
182
|
-
}
|
|
183
|
-
@Test fun inputDropDownPropsAndCallbacks() {
|
|
184
|
-
val a = inputDropDownArgsOf(mapOf("icon" to "x", "size" to "large", "errorMessage" to "e", "hintText" to "h", "required" to true,
|
|
185
|
-
"loading" to true, "disabled" to true, "errorSpacing" to true, "iconColor" to "#ff0000"), fire, hint, dflt)
|
|
186
|
-
assertEquals("x", a.icon); assertEquals(InputSize.LARGE, a.size); assertEquals("e", a.error); assertEquals("h", a.hintText)
|
|
187
|
-
assertTrue(a.required); assertTrue(a.loading); assertTrue(a.disabled); assertTrue(a.errorSpacing); assertEquals(Color(0xFFFF0000), a.iconColor)
|
|
188
|
-
a.onPress(); assertFired("onPress")
|
|
189
|
-
a.onRightIconPressed(); assertFired("onRightIconPressed")
|
|
190
|
-
}
|
|
191
|
-
@Test fun inputDropDownEmptyIconStaysEmpty() = assertEquals("", inputDropDownArgsOf(mapOf("icon" to ""), fire, hint, dflt).icon)
|
|
192
|
-
|
|
193
|
-
// ---- InputMoney
|
|
194
|
-
@Test fun inputMoneyDefaults() {
|
|
195
|
-
val a = inputMoneyArgsOf(emptyMap(), fire, hint, dflt)
|
|
196
|
-
assertEquals("0đ", a.placeholder); assertEquals(InputFontWeight.BOLD, a.fontWeight); assertEquals(KeyboardType.Number, a.keyboardType)
|
|
197
|
-
assertEquals(InputSize.SMALL, a.size); assertEquals(hint, a.floatingValueColor); assertEquals(dflt, a.iconColor)
|
|
198
|
-
}
|
|
199
|
-
@Test fun inputMoneyProps() {
|
|
200
|
-
val a = inputMoneyArgsOf(mapOf("placeholder" to "p", "fontWeight" to "regular", "keyboardType" to "decimal-pad", "trailing" to "t",
|
|
201
|
-
"leadingIcon" to "l", "errorMessage" to "e", "required" to true, "loading" to true), fire, hint, dflt)
|
|
202
|
-
assertEquals("p", a.placeholder); assertEquals(InputFontWeight.REGULAR, a.fontWeight); assertEquals(KeyboardType.Decimal, a.keyboardType)
|
|
203
|
-
assertEquals("t", a.icon); assertEquals("l", a.leadingIcon); assertEquals("e", a.error); assertTrue(a.required); assertTrue(a.loading)
|
|
204
|
-
}
|
|
205
|
-
@Test fun inputMoneyCallbacks() {
|
|
206
|
-
val a = inputMoneyArgsOf(emptyMap(), fire, hint, dflt)
|
|
207
|
-
a.onChangeText("5"); assertFired("onChangeText", "5")
|
|
208
|
-
a.onPressIcon(); assertFired("onPressTrailing")
|
|
209
|
-
a.onFocus(); assertFired("onFocus")
|
|
210
|
-
a.onBlur(); assertFired("onBlur")
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// ---- InputOTP
|
|
214
|
-
@Test fun inputOtpDefaults() {
|
|
215
|
-
val a = inputOtpArgsOf(emptyMap(), fire)
|
|
216
|
-
assertEquals("", a.value); assertNull(a.length); assertEquals("Label", a.floatingValue); assertEquals("number", a.dataType)
|
|
217
|
-
assertEquals("", a.placeholder); assertEquals("", a.errorMessage); assertFalse(a.errorSpacing)
|
|
218
|
-
}
|
|
219
|
-
@Test fun inputOtpProps() {
|
|
220
|
-
val a = inputOtpArgsOf(mapOf("value" to "12", "length" to 4, "floatingValue" to "F", "dataType" to "text", "errorMessage" to "e",
|
|
221
|
-
"errorSpacing" to true, "placeholder" to "*"), fire)
|
|
222
|
-
assertEquals("12", a.value); assertEquals(4, a.length); assertEquals("F", a.floatingValue); assertEquals("text", a.dataType)
|
|
223
|
-
assertEquals("e", a.errorMessage); assertTrue(a.errorSpacing); assertEquals("*", a.placeholder)
|
|
224
|
-
}
|
|
225
|
-
@Test fun inputOtpCallbacks() {
|
|
226
|
-
val a = inputOtpArgsOf(emptyMap(), fire)
|
|
227
|
-
a.onChangeText("9"); assertFired("onChangeText", "9")
|
|
228
|
-
a.onFocus(); assertFired("onFocus")
|
|
229
|
-
a.onBlur(); assertFired("onBlur")
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// ---- InputPhoneNumber
|
|
233
|
-
@Test fun inputPhoneDefaults() {
|
|
234
|
-
val a = inputPhoneNumberArgsOf(emptyMap(), fire, dflt)
|
|
235
|
-
assertEquals("0123456789", a.placeholder); assertEquals(InputPhoneNumberSize.SMALL, a.size); assertEquals(dflt, a.iconColor); assertFalse(a.loading)
|
|
236
|
-
}
|
|
237
|
-
@Test fun inputPhoneProps() {
|
|
238
|
-
val a = inputPhoneNumberArgsOf(mapOf("placeholder" to "p", "size" to "large", "hintText" to "h", "errorMessage" to "e",
|
|
239
|
-
"errorSpacing" to true, "trailing" to "t", "loading" to true), fire, dflt)
|
|
240
|
-
assertEquals("p", a.placeholder); assertEquals(InputPhoneNumberSize.LARGE, a.size); assertEquals("h", a.hintText); assertEquals("e", a.error)
|
|
241
|
-
assertTrue(a.errorSpacing); assertEquals("t", a.icon); assertTrue(a.loading)
|
|
242
|
-
}
|
|
243
|
-
@Test fun inputPhoneCallbacks() {
|
|
244
|
-
val a = inputPhoneNumberArgsOf(emptyMap(), fire, dflt)
|
|
245
|
-
a.onChangeText("0"); assertFired("onChangeText", "0")
|
|
246
|
-
a.onRightIconPressed(); assertFired("onPressTrailing")
|
|
247
|
-
a.onFocus(); assertFired("onFocus")
|
|
248
|
-
a.onBlur(); assertFired("onBlur")
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// ---- InputTextArea
|
|
252
|
-
@Test fun inputTextAreaDefaults() {
|
|
253
|
-
val a = inputTextAreaArgsOf(emptyMap(), fire, hint, dflt)
|
|
254
|
-
assertEquals(300, a.maxLength); assertEquals(104.dp, a.height); assertEquals(InputSize.SMALL, a.size); assertEquals(KeyboardType.Text, a.keyboardType)
|
|
255
|
-
assertEquals(InputFontWeight.REGULAR, a.fontWeight); assertEquals(hint, a.floatingValueColor); assertEquals(dflt, a.floatingIconColor); assertEquals(dflt, a.iconColor)
|
|
256
|
-
}
|
|
257
|
-
@Test fun inputTextAreaProps() {
|
|
258
|
-
val a = inputTextAreaArgsOf(mapOf("maxLength" to 50, "height" to 200, "size" to "large", "icon" to "i", "keyboardType" to "number-pad",
|
|
259
|
-
"fontWeight" to "bold", "required" to true, "loading" to true, "disabled" to true), fire, hint, dflt)
|
|
260
|
-
assertEquals(50, a.maxLength); assertEquals(200.dp, a.height); assertEquals(InputSize.LARGE, a.size); assertEquals("i", a.icon)
|
|
261
|
-
assertEquals(KeyboardType.Number, a.keyboardType); assertEquals(InputFontWeight.BOLD, a.fontWeight)
|
|
262
|
-
assertTrue(a.required); assertTrue(a.loading); assertTrue(a.disabled)
|
|
263
|
-
}
|
|
264
|
-
@Test fun inputTextAreaNegativeValuesFallBack() {
|
|
265
|
-
val a = inputTextAreaArgsOf(mapOf("maxLength" to -1, "height" to -5), fire, hint, dflt)
|
|
266
|
-
assertEquals(300, a.maxLength); assertEquals(0.dp, a.height)
|
|
267
|
-
}
|
|
268
|
-
@Test fun inputTextAreaCallbacks() {
|
|
269
|
-
val a = inputTextAreaArgsOf(emptyMap(), fire, hint, dflt)
|
|
270
|
-
a.onChangeText("t"); assertFired("onChangeText", "t")
|
|
271
|
-
a.onRightIconPressed(); assertFired("onRightIconPressed")
|
|
272
|
-
a.onFocus(); assertFired("onFocus")
|
|
273
|
-
a.onBlur(); assertFired("onBlur")
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// ---- Rating
|
|
277
|
-
@Test fun ratingDefaults() {
|
|
278
|
-
val a = ratingArgsOf(emptyMap(), none, fire)
|
|
279
|
-
assertEquals(0, a.numOfStars); assertEquals(0f, a.rating, 0f); assertEquals(RatingSize.LARGE, a.size); assertNull(a.onRatingChange)
|
|
280
|
-
}
|
|
281
|
-
// counts the kit draws one item per are capped: a spec value like 1e9 would compose that many items (hang / OOM)
|
|
282
|
-
@Test fun loopDrivingCountsAreCapped() {
|
|
283
|
-
assertEquals(MAX_SPEC_COUNT, ratingArgsOf(mapOf("numOfStars" to 1e9), none, fire).numOfStars)
|
|
284
|
-
assertEquals(MAX_SPEC_COUNT, ratingArgsOf(mapOf("numOfStars" to Double.POSITIVE_INFINITY), none, fire).numOfStars)
|
|
285
|
-
assertEquals(MAX_SPEC_COUNT, inputOtpArgsOf(mapOf("length" to 1e9), fire).length)
|
|
286
|
-
assertEquals(MAX_SPEC_COUNT, paginationArgsOf(mapOf("dataLength" to 1e9)).length)
|
|
287
|
-
assertEquals(MAX_SPEC_COUNT, paginationArgsOf(mapOf("dataLength" to 1e9)).numberLength)
|
|
288
|
-
// ordinary values untouched
|
|
289
|
-
assertEquals(5, ratingArgsOf(mapOf("numOfStars" to 5), none, fire).numOfStars)
|
|
290
|
-
assertEquals(6, inputOtpArgsOf(mapOf("length" to 6), fire).length)
|
|
291
|
-
assertEquals(MAX_SPEC_COUNT, paginationArgsOf(mapOf("dataLength" to MAX_SPEC_COUNT)).length)
|
|
292
|
-
}
|
|
293
|
-
@Test fun ratingPropsAndCallback() {
|
|
294
|
-
val a = ratingArgsOf(mapOf("numOfStars" to 5, "rating" to 3.5, "size" to "small"), all, fire)
|
|
295
|
-
assertEquals(5, a.numOfStars); assertEquals(3.5f, a.rating, 0f); assertEquals(RatingSize.SMALL, a.size)
|
|
296
|
-
a.onRatingChange!!(4); assertFired("onRatingChange", 4L)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// ---- Slider
|
|
300
|
-
@Test fun sliderDefaults() {
|
|
301
|
-
val a = sliderArgsOf(emptyMap(), fire)
|
|
302
|
-
assertEquals(0f, a.min, 0f); assertEquals(100f, a.max, 0f); assertEquals(1f, a.step, 0f); assertNull(a.low); assertNull(a.high)
|
|
303
|
-
assertEquals(0f, a.minRange, 0f); assertFalse(a.disableRange); assertFalse(a.floatingLabel); assertFalse(a.disabled)
|
|
304
|
-
}
|
|
305
|
-
@Test fun sliderProps() {
|
|
306
|
-
val a = sliderArgsOf(mapOf("min" to 10, "max" to "20", "step" to 2, "low" to 12, "high" to 18, "minRange" to 1,
|
|
307
|
-
"disableRange" to true, "floatingLabel" to true, "disabledLow" to true, "disabledHigh" to true), fire)
|
|
308
|
-
assertEquals(10f, a.min, 0f); assertEquals(20f, a.max, 0f); assertEquals(2f, a.step, 0f); assertEquals(12f, a.low)
|
|
309
|
-
assertEquals(18f, a.high); assertEquals(1f, a.minRange, 0f); assertTrue(a.disableRange); assertTrue(a.floatingLabel); assertTrue(a.disabled)
|
|
310
|
-
}
|
|
311
|
-
@Test fun sliderCallbacks() {
|
|
312
|
-
val a = sliderArgsOf(emptyMap(), fire)
|
|
313
|
-
a.onValueChanged(10f, 20.5f, true); assertFired("onValueChanged", 10L, 20.5, true)
|
|
314
|
-
a.onSliderTouchStart(1f, 2f); assertFired("onSliderTouchStart", 1L, 2L)
|
|
315
|
-
a.onSliderTouchEnd(3f, 4.5f); assertFired("onSliderTouchEnd", 3L, 4.5)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// ---- Stepper
|
|
319
|
-
@Test fun stepperDefaults() {
|
|
320
|
-
val a = stepperNodeArgsOf(emptyMap(), fire)
|
|
321
|
-
assertEquals(StepperArgs(0, 0, 100, 1), a.numbers); assertEquals(false, a.disabled); assertEquals(StepperSize.LARGE, a.size); assertFalse(a.editable)
|
|
322
|
-
}
|
|
323
|
-
@Test fun stepperProps() {
|
|
324
|
-
val a = stepperNodeArgsOf(mapOf("min" to 5, "max" to 1, "defaultValue" to 9, "step" to 2, "size" to "small", "editable" to true,
|
|
325
|
-
"disabled" to listOf(true, false)), fire)
|
|
326
|
-
assertEquals(StepperArgs(5, 5, 5, 2), a.numbers); assertEquals(StepperSize.SMALL, a.size); assertTrue(a.editable)
|
|
327
|
-
assertArrayEquals(booleanArrayOf(true, false), a.disabled as BooleanArray)
|
|
328
|
-
}
|
|
329
|
-
@Test fun stepperCallback() {
|
|
330
|
-
stepperNodeArgsOf(emptyMap(), fire).onValueChange(7); assertFired("onValueChange", 7L)
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// ---- Steps
|
|
334
|
-
@Test fun stepsDefaults() {
|
|
335
|
-
val a = stepsNodeArgsOf(emptyMap(), none, fire)
|
|
336
|
-
assertEquals(emptyList<StepItem>(), a.steps); assertEquals(0, a.activeIndex); assertFalse(a.horizontal); assertFalse(a.useNumber)
|
|
337
|
-
assertEquals(StepsAlign.CENTER, a.align); assertNull(a.customIcon); assertFalse(a.disabled); assertNull(a.onPress)
|
|
338
|
-
}
|
|
339
|
-
@Test fun stepsPropsAndCallback() {
|
|
340
|
-
val a = stepsNodeArgsOf(mapOf("steps" to listOf(mapOf("title" to "A", "error" to true)), "activeIndex" to 1, "horizontal" to true,
|
|
341
|
-
"useNumber" to true, "align" to "left", "customIcon" to "ci", "disabled" to true), all, fire)
|
|
342
|
-
assertEquals(listOf(StepItem("A", null, true, null)), a.steps); assertEquals(1, a.activeIndex); assertTrue(a.horizontal)
|
|
343
|
-
assertTrue(a.useNumber); assertEquals(StepsAlign.LEFT, a.align); assertEquals("ci", a.customIcon); assertTrue(a.disabled)
|
|
344
|
-
val s = StepItem("B", "d", false, "t")
|
|
345
|
-
a.onPress!!(s, 2); assertFired("onPress", stepArg(s), 2L)
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// ---- ProgressInfo
|
|
349
|
-
@Test fun progressInfoDefaultsAndProps() {
|
|
350
|
-
val d = progressInfoArgsOf(emptyMap())
|
|
351
|
-
assertTrue(d.showTitle); assertTrue(d.showDescription); assertFalse(d.horizontal); assertFalse(d.useNumber); assertNull(d.customIcon)
|
|
352
|
-
assertEquals(emptyList<Any>(), d.steps)
|
|
353
|
-
val a = progressInfoArgsOf(mapOf("steps" to listOf(mapOf("title" to "T", "description" to "D")), "showTitle" to false,
|
|
354
|
-
"showDescription" to false, "horizontal" to true, "useNumber" to true, "customIcon" to "c"))
|
|
355
|
-
assertFalse(a.showTitle); assertFalse(a.showDescription); assertTrue(a.horizontal); assertTrue(a.useNumber); assertEquals("c", a.customIcon)
|
|
356
|
-
assertEquals("T", a.steps.single().title); assertEquals("D", a.steps.single().description)
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// ---- Collapse
|
|
360
|
-
@Test fun collapseDefaults() {
|
|
361
|
-
val a = collapseArgsOf(emptyMap(), fire)
|
|
362
|
-
assertEquals("Title", a.title); assertNull(a.description); assertNull(a.image); assertEquals(24, a.imageSize); assertNull(a.subTitle)
|
|
363
|
-
assertNull(a.tagLabel); assertEquals(TagColor.Default, a.tagColor); assertFalse(a.showBorder); assertFalse(a.expandDefault)
|
|
364
|
-
assertEquals(CollapseTitleSize.Medium, a.titleSize); assertFalse(a.useBackgroundCollapseButton); assertNull(a.backgroundColor)
|
|
365
|
-
assertNull(a.titleColor); assertNull(a.accessibilityId)
|
|
366
|
-
}
|
|
367
|
-
@Test fun collapseProps() {
|
|
368
|
-
val a = collapseArgsOf(mapOf("title" to "T", "description" to "D", "image" to "i", "imageSize" to 40, "showBorder" to true,
|
|
369
|
-
"expandDefault" to true, "titleSize" to "large", "useBackgroundCollapseButton" to true, "backgroundColor" to "#ff0000",
|
|
370
|
-
"titleColor" to "#00ff00", "accessibilityLabel" to "acc", "tagProps" to mapOf("label" to "New", "color" to "green")), fire)
|
|
371
|
-
assertEquals("T", a.title); assertEquals("D", a.description); assertEquals("i", a.image); assertEquals(40, a.imageSize)
|
|
372
|
-
assertTrue(a.showBorder); assertTrue(a.expandDefault); assertEquals(CollapseTitleSize.Large, a.titleSize); assertTrue(a.useBackgroundCollapseButton)
|
|
373
|
-
assertEquals(Color(0xFFFF0000), a.backgroundColor); assertEquals(Color(0xFF00FF00), a.titleColor); assertEquals("acc", a.accessibilityId)
|
|
374
|
-
assertEquals("New", a.tagLabel); assertEquals(TagColor.Green, a.tagColor)
|
|
375
|
-
}
|
|
376
|
-
@Test fun collapseSubTitleHidesTagLabel() {
|
|
377
|
-
val a = collapseArgsOf(mapOf("subTitle" to "S", "tagProps" to mapOf("label" to "New")), fire)
|
|
378
|
-
assertEquals("S", a.subTitle); assertNull(a.tagLabel)
|
|
379
|
-
}
|
|
380
|
-
@Test fun collapseCallback() {
|
|
381
|
-
collapseArgsOf(emptyMap(), fire).onPress(true); assertFired("onPress", true)
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// ---- SuggestAction
|
|
385
|
-
@Test fun suggestActionDefaults() {
|
|
386
|
-
val a = suggestActionArgsOf(emptyMap(), fire)
|
|
387
|
-
assertEquals("Message", a.message); assertEquals("Button", a.buttonTitle); assertEquals("", a.boldMessage); assertEquals("", a.image); assertFalse(a.visible)
|
|
388
|
-
}
|
|
389
|
-
@Test fun suggestActionPropsAndCallbacks() {
|
|
390
|
-
val a = suggestActionArgsOf(mapOf("message" to "m", "buttonTitle" to "b", "boldMessage" to "bm", "image" to "i", "visible" to true), fire)
|
|
391
|
-
assertEquals("m", a.message); assertEquals("b", a.buttonTitle); assertEquals("bm", a.boldMessage); assertEquals("i", a.image); assertTrue(a.visible)
|
|
392
|
-
a.onClose(); assertFired("onClose")
|
|
393
|
-
a.onPressButton(); assertFired("onPressButton")
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// ---- TrustBanner
|
|
397
|
-
@Test fun trustBannerDefaults() {
|
|
398
|
-
val a = trustBannerArgsOf(emptyMap(), none, fire)
|
|
399
|
-
assertEquals("", a.serviceName); assertEquals("", a.screenName); assertNull(a.onPress); assertNull(a.trackEvent)
|
|
400
|
-
}
|
|
401
|
-
@Test fun trustBannerPropsAndCallbacks() {
|
|
402
|
-
val a = trustBannerArgsOf(mapOf("serviceName" to "s", "screenName" to "n"), all, fire)
|
|
403
|
-
assertEquals("s", a.serviceName); assertEquals("n", a.screenName)
|
|
404
|
-
a.onPress!!(mapOf("k" to "v")); assertFired("onPress", mapOf("k" to "v"))
|
|
405
|
-
a.trackEvent!!("evt", mapOf("k" to "v")); assertFired("trackEvent", "evt", mapOf("k" to "v"))
|
|
406
|
-
}
|
|
407
|
-
@Test fun trustBannerHandlersAreIndependent() {
|
|
408
|
-
val a = trustBannerArgsOf(emptyMap(), { it == "trackEvent" }, fire)
|
|
409
|
-
assertNull(a.onPress); assertNotNull(a.trackEvent)
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// ---- Uploader
|
|
413
|
-
@Test fun uploaderDefaults() {
|
|
414
|
-
val a = uploaderArgsOf(emptyMap(), none, fire)
|
|
415
|
-
assertEquals(emptyList<UploadImage>(), a.images); assertEquals(1, a.numberOfImages); assertFalse(a.disabled)
|
|
416
|
-
assertEquals(64.dp, a.width); assertEquals(64.dp, a.height); assertNull(a.onCancel)
|
|
417
|
-
}
|
|
418
|
-
@Test fun uploaderPropsAndCallbacks() {
|
|
419
|
-
val img = UploadImage("u", true)
|
|
420
|
-
val a = uploaderArgsOf(mapOf("images" to listOf(mapOf("uri" to "u", "loading" to true)), "numberOfImages" to 3, "disabled" to true,
|
|
421
|
-
"width" to 80, "height" to 90), all, fire)
|
|
422
|
-
assertEquals(listOf(img), a.images); assertEquals(3, a.numberOfImages); assertTrue(a.disabled); assertEquals(80.dp, a.width); assertEquals(90.dp, a.height)
|
|
423
|
-
a.onAdd(); assertFired("onAdd")
|
|
424
|
-
a.onCancel!!(img, 2); assertFired("onCancel", imageArg(img), 2L)
|
|
425
|
-
a.onPressImage(img, 1); assertFired("onPressImage", imageArg(img), 1L)
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// ---- Swipe
|
|
429
|
-
private val leftSpec = listOf(mapOf("label" to "Del", "icon" to "ic", "backgroundColor" to "#ff0000", "actions" to listOf(mapOf("type" to "x"))))
|
|
430
|
-
@Test fun swipeDefaults() {
|
|
431
|
-
val a = swipeArgsOf(emptyMap(), emptyMap(), fire) { }
|
|
432
|
-
assertEquals(56.dp, a.rowHeight); assertNull(a.radius); assertTrue(a.leftActions.isEmpty()); assertTrue(a.rightActions.isEmpty())
|
|
433
|
-
}
|
|
434
|
-
@Test fun swipeHeightAndRadius() {
|
|
435
|
-
val a = swipeArgsOf(mapOf("height" to 80, "itemRadius" to 12), emptyMap(), fire) { }
|
|
436
|
-
assertEquals(80.dp, a.rowHeight); assertEquals(12.dp, a.radius)
|
|
437
|
-
assertEquals(0.dp, swipeArgsOf(mapOf("itemRadius" to -4), emptyMap(), fire) { }.radius)
|
|
438
|
-
}
|
|
439
|
-
@Test fun swipeActionsPressRawActionsAsOnPress() {
|
|
440
|
-
val pressed = mutableListOf<List<Any?>>()
|
|
441
|
-
val p = mapOf("leftActions" to leftSpec)
|
|
442
|
-
val a = swipeArgsOf(p, p, fire) { pressed += it }
|
|
443
|
-
val l = a.leftActions.single()
|
|
444
|
-
assertEquals("Del", l.label); assertEquals("ic", l.icon); assertEquals(Color(0xFFFF0000), l.backgroundColor)
|
|
445
|
-
assertTrue(a.rightActions.isEmpty())
|
|
446
|
-
l.onPress()
|
|
447
|
-
assertEquals(1, pressed.size)
|
|
448
|
-
assertEquals(mapOf("type" to "x", "name" to "onPress").let { listOf(it) }, pressed.single().map { it.asMap()!!.let { m -> m + ("name" to "onPress") } })
|
|
449
|
-
}
|
|
450
|
-
@Test fun swipeRightActionsAndMaxThree() {
|
|
451
|
-
val side = List(5) { mapOf("label" to "A$it") }
|
|
452
|
-
val a = swipeArgsOf(mapOf("rightActions" to side), mapOf("rightActions" to side), fire) { }
|
|
453
|
-
assertEquals(listOf("A0", "A1", "A2"), a.rightActions.map { it.label })
|
|
454
|
-
}
|
|
455
|
-
@Test fun swipeCallbacks() {
|
|
456
|
-
val a = swipeArgsOf(emptyMap(), emptyMap(), fire) { }
|
|
457
|
-
a.onSwipeableOpen(); assertFired("onSwipeableOpen")
|
|
458
|
-
a.onSwipeableClose(); assertFired("onSwipeableClose")
|
|
459
|
-
a.onSwipeableLeftOpen(); assertFired("onSwipeableLeftOpen")
|
|
460
|
-
a.onSwipeableRightOpen(); assertFired("onSwipeableRightOpen")
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// ---- PopupNotify
|
|
464
|
-
@Test fun popupNotifyDefaults() {
|
|
465
|
-
val a = popupNotifyPropsOf(emptyMap(), emptyMap(), fire) { }
|
|
466
|
-
assertEquals("", a.image); assertEquals("Title", a.title); assertEquals("Description", a.description); assertEquals("", a.error)
|
|
467
|
-
assertNull(a.primary); assertNull(a.secondary); assertEquals(PopupActionDirection.ROW, a.buttonDirection); assertTrue(a.isShowCloseIcon)
|
|
468
|
-
}
|
|
469
|
-
@Test fun popupNotifyProps() {
|
|
470
|
-
val p = mapOf("image" to "i", "title" to "T", "description" to "D", "error" to "E", "buttonDirection" to "column", "isShowCloseIcon" to false)
|
|
471
|
-
val a = popupNotifyPropsOf(p, p, fire) { }
|
|
472
|
-
assertEquals("i", a.image); assertEquals("T", a.title); assertEquals("D", a.description); assertEquals("E", a.error)
|
|
473
|
-
assertEquals(PopupActionDirection.COLUMN, a.buttonDirection); assertFalse(a.isShowCloseIcon)
|
|
474
|
-
a.onIconClose(); assertFired("onIconClose")
|
|
475
|
-
}
|
|
476
|
-
@Test fun popupNotifyButtonsPressRawActionsAsOnPress() {
|
|
477
|
-
val pressed = mutableListOf<List<Any?>>()
|
|
478
|
-
val p = mapOf("primary" to mapOf("title" to "OK", "actions" to listOf(mapOf("type" to "go"))), "secondary" to mapOf("title" to "No"))
|
|
479
|
-
val a = popupNotifyPropsOf(p, p, fire) { pressed += it }
|
|
480
|
-
assertEquals("OK", a.primary!!.title); assertEquals("No", a.secondary!!.title)
|
|
481
|
-
a.primary!!.onPress!!()
|
|
482
|
-
assertEquals(listOf(listOf(mapOf("type" to "go", "name" to "onPress"))), pressed)
|
|
483
|
-
a.secondary!!.onPress!!()
|
|
484
|
-
assertEquals(emptyList<Any?>(), pressed.last())
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// ---- PopupPromotion
|
|
488
|
-
@Test fun popupPromotionDefaultsAndCallbacks() {
|
|
489
|
-
val d = popupPromotionArgsOf(emptyMap(), fire)
|
|
490
|
-
assertEquals("", d.source)
|
|
491
|
-
d.onPress(); assertFired("onActionClick")
|
|
492
|
-
d.onClose(); assertFired("onIconClose")
|
|
493
|
-
assertEquals("img", popupPromotionArgsOf(mapOf("image" to "img"), fire).source)
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// ---- shared
|
|
497
|
-
@Test fun textPropIsEmptyWhenAbsent() {
|
|
498
|
-
assertEquals("", textProp(emptyMap(), "k")); assertEquals("v", textProp(mapOf("k" to "v"), "k")); assertEquals("5", textProp(mapOf("k" to 5), "k"))
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// ---- gatedFire: dispatch only for callbacks the node declares
|
|
502
|
-
private val dispatched = mutableListOf<Triple<List<Any?>, String, List<Any?>>>()
|
|
503
|
-
private fun gated(node: Node) = gatedFire(node) { acts, name, args -> dispatched += Triple(acts, name, args) }
|
|
504
|
-
|
|
505
|
-
@Test fun gatedFireDispatchesTheNodesActionsForThatName() {
|
|
506
|
-
val act = mapOf("name" to "onChange", "type" to "setState")
|
|
507
|
-
val other = mapOf("name" to "onBlur", "type" to "log")
|
|
508
|
-
gated(mapOf("type" to "Switch", "actions" to listOf(act, other)))("onChange", listOf(true))
|
|
509
|
-
assertEquals(listOf(Triple(listOf<Any?>(act), "onChange", listOf<Any?>(true))), dispatched)
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
@Test fun gatedFireDispatchesNothingWhenTheNodeDeclaresNoSuchAction() {
|
|
513
|
-
gated(mapOf("type" to "Switch", "actions" to listOf(mapOf("name" to "onBlur"))))("onChange", listOf(true))
|
|
514
|
-
gated(mapOf("type" to "Switch"))("onChange", listOf(true))
|
|
515
|
-
assertTrue(dispatched.isEmpty())
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
@Test fun gatedFireDispatchesThePropFormCallback() {
|
|
519
|
-
val inProp = mapOf("type" to "setState", "params" to mapOf("x" to 1L))
|
|
520
|
-
gated(mapOf("type" to "Uploader", "props" to mapOf("onAdd" to inProp)))("onAdd", emptyList())
|
|
521
|
-
assertEquals(listOf(Triple(listOf<Any?>(inProp + ("name" to "onAdd")), "onAdd", emptyList<Any?>())), dispatched)
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
// AI-GENERATED END: SDUI kit args tests
|