我试图测试调用move动作将导致模态视图的控制器设置正确的模型。
asyncTest("attempting to move directories will setup the folder_tree_controller's model", 1, ->
User.create({email: '[email protected]', session: 'session_token', card: Cards.FIXTURES[0].id})
cardController = App.__container__.lookup('controller:card')
Em.run -> cardController.set('model', null)
Em.run -> controller.send('move')
wait()
ok(cardController.get('model'))
start()
)
控制器要点:
Controller = Ember.Controller.extend({
actions: {
move: ->
self = @
@get('store').find('card', User.current().directory).then (card) ->
self.send('showMoveDialog', card)
false
}
})
但是,在执行测试期间,我会出错并收到以下消息:
Error: Can't trigger action 'showMoveDialog' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks.
Source:
at Test.QUnitAdapter.Test.Adapter.extend.exception (http://localhost:8000/vendor/ember/index.js:40219:5)
at superWrapper [as exception] (http://localhost:8000/vendor/ember/index.js:1230:16)
at Ember.RSVP.onerrorDefault (http://localhost:8000/vendor/ember/index.js:16520:28)
at Object.__exports__.default.trigger (http://localhost:8000/vendor/ember/index.js:8399:13)
at Promise._onerror (http://localhost:8000/vendor/ember/index.js:9123:16)
at Promise.publishRejection (http://localhost:8000/vendor/ember/index.js:9530:17)
at Object.DeferredActionQueues.flush (http://localhost:8000/vendor/ember/index.js:5654:24)
at Object.Backburner.end (http://localhost:8000/vendor/ember/index.js:5745:27)
在尝试测试模式视图时是否缺少某些内容?
像这样设置您的控制器,它将能够在您的测试中调用send:
cardController = App.CardController.create({
container: App.__container__
});
这与执行容器.lookup(...)相反
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句