Results 1 to 3 of 3

Thread: Test a Sencha Touch Controller using Jasmine

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    24
    Vote Rating
    1
      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 User arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,516
    Vote Rating
    77
      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
      0  

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •