it('should save user', function () { var destName = 'Carlos'; var event = $.Event('click'); spyOn(this.view, 'killEvent'); spyOn(this.view, '_getUserFields').and.returnValue({ name: NAME }); spyOn(this.view, '_getDestinationValues').and.returnValue({ name: destName }); spyOn(this.view._userModel, 'save'); this.view._onClickSave(event); expect(this.view.killEvent).toHaveBeenCalledWith(event); expect(this.view._userModel.save).toHaveBeenCalledWith({ user: { name: destName } }, { wait: true, url: '/api/v3/me', success: this.showSuccessSpy, error: this.showErrorsSpy }); });
function keyPressEvent(key, metaKey) { var event = $.Event('keydown'); event.which = key; event.keyCode = key; if (metaKey) { event.metaKey = true; } return event; }
it('should submit update', function () { spyOn(this.view.sendButton, 'onUpdate'); var e = $.Event('keydown'); e.keyCode = e.which = 13; e.metaKey = true; this.view.$el.find('#carto_notification_body').trigger(e); expect(this.view.sendButton.onUpdate).toHaveBeenCalled(); });