I'm trying to run an Ember controller in a Jasmine test, and it's giving me some trouble.
This spec works, in that it renders the controller, and most of the controller is rendered accurately and can be tested.
However, there is clearly a difference between how I'm setting up these objects in the test, and how Ember sets them up at run time, because parts of the controller are not working in the test...
Details:
-
The itemController is not accessed at all, which means that the reference to "startDateDisplay" (which is defined in the item controller) comes up empty.
-
In a probably related story, the action referenced in the template can not be triggered in the test with a $(".trip").click() jQuery event.
I tried a few workarounds -- I tried changing the {{each}} in the template to:
{{#each trip in controller}}
Which gives me the error
Error: assertion failed: an Ember.CollectionView's content must implement Ember.Array. You passed <TimeTravel.IndexTripController:ember258>
Which I take to mean that whatever magic causes looping over a controller to refer to its content is not being invoked when rendered in the test.
I also tried the more explicit
{{#each trip in controller.content itemController="IndexTrip"}}
Which fails with
TypeError: Cannot call method 'child' of null
at Ember.ArrayController.Ember.ArrayProxy.extend.controllerAt (http://js_travel.dev/assets/ember.js?body=1:12492:53)
at Ember.ArrayController.Ember.ArrayProxy.extend.objectAtContent (http://js_travel.dev/assets/ember.js?body=1:12445:21)
Which I don't get at all, but has something to do with containers.
The above seems wrong since you've said that
IndexTripController
is anObjectController
. Am I mistaken?