Skip to content

Instantly share code, notes, and snippets.

@hatched
Created June 29, 2013 15:23
Show Gist options
  • Save hatched/5891527 to your computer and use it in GitHub Desktop.
Save hatched/5891527 to your computer and use it in GitHub Desktop.
MyClass = {
makeIOCall: function(url) {
Y.io(url, {
on: {
success: this.successHandler
}
}
}
successHandler: function(id, o, args) {
// do something with these params
return Y.JSON.parse(o.responseText);
}
}
// in your test
// using mocha syntax (convert to whatever engine you are using)
it('can properly parse server response data', function() {
var data = myClass.successHandler('foo', { server: 'data'});
assert(data.server, 'data', 'Did not parse json properly');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment