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

    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 - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,363
    Vote Rating
    33
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      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.
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

  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