I have a JS method I'm looking to test:
doMediation: function() {
var state,
that = this,
mediation_rule = "asdf";
Mediation.getRules(mediation_rule, function () {
[blah blah]
});
},
My Mediation object is defined above this method in my class. This is my qunit test:
test('doMediation: testing mediation', 1, function(){
var proto = $.extend({}, My.prototype, {
Mediation: {
getRules: function(rule, cb){}
}
proto.doMediation();
});
The problem is that I'm getting an error:
Died on test #1: Cannot call method 'getRules' of undefined - {}
Yet, it is defined right there in the test. Thanks.
Turns out that previously, Mediation was defined as such: var Mediation = AnotherClass.Mediation. In the qunit test, I had to actually define AnotherClass.Mediation = {} instead of Mediation{}