coffeescript - How to stub a super() call with Sinon -


i using coffeescript , i'm testing using sinon.js. when testing method invokes method overwrites, how can stub call super()?

e.g., method want test (a backbone.js model):

class whatever extends model   validate: (attributes) ->     validationerrors = super(attributes)     ...     validationerrors 

in example, want make sure super() invoked given attributes , validate returns validation errors super() returns.

like this:

it 'calls super , returns result', ->   whatever = new whatever()   attributes = sinon.stub()   supervalidatestub = sinon.mock(whatever.__super__)   supervalidatestub.expects('validate').withexactargs(attributes).returns('validation_result')    expect(whatever.validate(attributes)).to.eql('validation_result')    supervalidatestub.verify() 

hope helps anyone.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -