Saturday, January 14, 2012

how one calls "methods" and passes parameters to the "methods" of Jasmine-friendly widgets

I'll blog more about the framework for using Jasmine later. I want to mention now how one calls methods and passes parameters to the methods of Jasmine-friendly widgets. If one has this in whatever.js...

getOption: function (name) {

   var self = this;

   return self.options[name];

},

options: {

   foo: "bar",

   baz: "qux"

}

 
 

One may interface with getOption method in whatever.js from whatever.spec.js like so:

var currentFoo = widget.Whatever('getOption', 'foo');

 
 

The first "parameter" is the name of the "method" and the subsequent parameters are the parameters for the method. I put "method" in quotes, because I'm not sure what to call these "things" just yet. (I'm learning. Cut me some slack.)

No comments:

Post a Comment