I'm trying to write some tests for a controller using Jasmine. For example, I've got an action method that looks like this:
Code:
mapContact : function(params) {
// Do some stuff here
this.application.contactPanel.setActiveItem(contactMapPanel, {type:'slide', direction:'left'});
}
where contactMapPanel is a panel contained within contactPanel. What is the best way to test this method in Jasmine? How can I test that the active item is indeed correctly set to contactMapPanel?
Testing things via Jasmine is going to be a bit tough, because it depends on the entire environment... which sort-of defeats the "unit" you're testing. Given that this method (setActiveItem) exists in the framework itself, I don't see why you even want to test that - you should trust the framework and focus your testing efforts on your own logic.
But... assuming you want to continue on your quest anyways, you will need to assert that this.application.contactPanel.getActiveItem() is the component you're expecting.
As I said before, this isn't really a "unit" test... it's an integration test. Two different things, technically - but an important distinction because Jasmine isn't really meant for integration testing.