KT-2752: fix some tests and make them slightly less fragile
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package helpers
|
||||
|
||||
fun checkJsNames(base: String, o: Any) {
|
||||
val regex = Regex("^$base(_[0-9a-zA-Z]+\\\$)?(_[0-9])?$")
|
||||
|
||||
val properties = getAllProperties(o).filter { it.startsWith("$base") }
|
||||
val distinctProperties = properties.mapNotNull { regex.match(it)?.groupValues?.get(1) }.distinct()
|
||||
if (distinctProperties.size != 2) {
|
||||
fail("Two distinct properties expected, ${properties.size} occurred: " + properties)
|
||||
}
|
||||
}
|
||||
|
||||
fun getAllProperties(o: dynamic): Array<String> = js("""
|
||||
var properties = [];
|
||||
for (property in o) {
|
||||
properties.push(property);
|
||||
}
|
||||
return properties;
|
||||
""")
|
||||
Reference in New Issue
Block a user