vue-test-utils:触发keydown.tab时,焦点元素未更改

时间:2020-10-01 07:45:53

标签: javascript vue.js jestjs dom-events vue-test-utils

请考虑以下测试代码。当使用包装器触发标签时,按焦点元素不会更改。

我做错了还是对包装器行为的期望错了?

预期结果:export default function VaccinationListScreen(props) { const [expand, setExpand] = useState(false); const [data, setData] = useState(""); const VaccinationListItem = (item) => { const [expand, setExpand] = useState(false); return ( <TouchableOpacity style={{ padding: 10 }} onPress={() => setExpand(true)}> <View style={{ padding: 10, backgroundColor: "#fff", elevation: 3, margin: "2%", borderRadius: 5, }} key={item.id} > <View style={{ alignItems: "flex-end" }}> <Text style={{ color: "grey", fontSize: 12 }}> {item.display_date} </Text> </View> <View style={{ flexDirection: "row" }}> <View> <Image source={require("../../assets/atbirth.jpg")} style={{ height: 40, width: 50 }} resizeMode="contain" /> </View> <View style={{ flex: 1 }}> <View style={{ flexDirection: "row", flex: 1 }}> <Text key={item.id} style={{ fontFamily: "Roboto", fontSize: 18, fontWeight: "bold", }} > {item.name} </Text> </View> <View style={{ flexDirection: "row", width: "30%" }}> {item.vaccine_list.map((i) => { return ( <View style={{ flexDirection: "row" }}> <Text numberOfLines={1} ellipsizeMode="tail" style={{ fontFamily: "Roboto", fontSize: 15 }} > {i.name}, </Text> </View> ); })} </View> </View> </View> <View style={{ alignItems: "flex-end", marginTop: "1%" }}> <View style={{ flexDirection: "row" }}> <Text style={{ color: "red", fontSize: 14, fontWeight: "bold", }} > {item.child_vacc_status.text} </Text> <Icon name="chevron-up" color="red" size={12} style={{ marginTop: "1%", marginLeft: "1%" }} /> </View> </View> </View> </TouchableOpacity> ); }; return ( <SafeAreaView> <ScrollView> {data != undefined && data != null && data.map((item) => { VaccinationListItem(item); })} </ScrollView> </SafeAreaView> ); } 被聚焦

实际结果:#bar被关注

#foo

0 个答案:

没有答案