我正在使用Jasmine对EmberJS项目进行单元测试,但我遇到了Ember需求API的问题.
当我尝试运行jasmine测试时,如果有问题的控制器有"需要"以及调用的init函数,则它们无法创建控制器实例
this._super()
我收到此控制台错误
"无法调用方法'有'null'
当我试图调试时,把我带到了Ember的肠道,但我无处可去.
任何人都知道我做错了什么
Application.SearchPendingController = Ember.ObjectController.extend({
needs: ['searchResults', 'search'],
shouldDisable: false,
searchResultsController: null,
init: function () {
this._super();
this.set('searchResultsController', this.controllerFor('searchResults'));
this.get('controllers.search.content').reload();
this.get('controllers.searchResults').set('content', this.get('controllers.search.content.results'));
},
transitionToResults: function () {
console.log('yay');
}.observes('this.searchResultsController.content')
});
Run Code Online (Sandbox Code Playgroud)
当我尝试创建此控制器时,jasmine测试会抛出错误
var searchPendingController = Application.SearchPendingController.create();
Run Code Online (Sandbox Code Playgroud)
有人对此有什么想法吗?