如何使用 karma 测试 jasmine 中的 forEach 循环?组件代码如下:-
getData(studentsList:any, day:any, game:any){
let strength:any;
let location:string;
if(studentsList){
studentsList.forEach( value => {
strength=value.schedule[day][game].strength;
location=value.schedule[day][game].location;
});
}
}
Run Code Online (Sandbox Code Playgroud)
StudentsList 中存在的数据是:-
(编辑:-数据已更新,看起来像这样)
[{
"activityName": "tournament1",
"schedule": {
"first": {
"Baseball": {
"strength": 23,
"location": "abc"
}
},
"second": {
"Cricket": {
"strength": 20,
"location": "bcd"
}
},
"third": {
"Football": {
"strength": 19,
"location": "cde"
}
}
}
},
{
"activityName": "tournament2",
"schedule": {
"first": {
"Baseball": {
"strength": 23,
"location": "abc"
}
},
"second": …Run Code Online (Sandbox Code Playgroud)