我正在尝试在余烬单元测试用例中获取模型值,但是它的抛出错误,例如currentModel被破坏或未定义。
单元测试代码:
test('test userInfo', function (assert) {
let appRoute = this.subject();
let response = {
"name ": "Test User"
}
appRoute.getUserInfo(response);
assert.equal(appRoute.get('currentModel.userInfo'), response.name, "userInfo value");
assert.ok(appRoute);
});
应用程序路由代码:
getUserInfo: function (response) {
this.set('currentModel.userInfo', response.name);
},