1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    24
    Vote Rating
    1
    buffalo billion is on a distinguished road

      0  

    Default Test a Sencha Touch Controller using Jasmine

    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?

  2. #2
    Sencha - Tools Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,475
    Vote Rating
    69
    arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light

      0  

    Default

    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.

    http://docs.sencha.com/touch/1-1/#!/...-getActiveItem

    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.

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    24
    Vote Rating
    1
    buffalo billion is on a distinguished road

      0  

    Default

    Ah, yes--thanks @arthurakay, that makes sense. I will stick with unit testing using Jasmine.

Thread Participants: 1