Created
October 2, 2014 15:52
-
-
Save StevenLangbroek/98be7a6ee4d013029ecf to your computer and use it in GitHub Desktop.
Sync example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "Saving", -> | |
| before -> | |
| @syncSpy = sinon.spy() | |
| @syncStub = sinon.stub(Backbone, 'sync', @syncSpy) | |
| @changeSpy = sinon.spy() | |
| afterEach -> | |
| @syncSpy.reset() | |
| it 'sets errors on the model when trying to save', -> | |
| application.on('change:_errors', @changeSpy) | |
| application.save(null, validate: true) | |
| @changeSpy.should.have.been.calledOnce | |
| @syncSpy.should.not.have.been.called | |
| it 'should skip validation by default', -> | |
| application.save() | |
| @syncSpy.calledWith('create', application, sinon.match.any).should.be.ok | |
| @syncSpy.should.be.calledOnce |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment