Using the jQuery widget factory, i want to test internally that methods get called. How can I expose those methods to spy on them?
$.widget 'foo',
_init: ->
@_bar()
_bar ->
barSpy = sinon.spy WidgetPluginObject, '_bar'
$('#foo').foo()
expect(barSpy).to.be.called.once
I am looking to reference the widget plugin object (represented here by WidgetPluginObject
so I can spy on it's methods.
UPDATE
This is for the purposes of unit testing using mocha/chai; not for any sort of debugging.