spec_app/spec/javascripts/up/modal_spec.js.coffee in unpoly-rails-0.56.6 vs spec_app/spec/javascripts/up/modal_spec.js.coffee in unpoly-rails-0.56.7

- old
+ new

@@ -658,10 +658,11 @@ next => expect(up.modal.isOpen()).toBe(false) expect(backgroundClicked).not.toHaveBeenCalled() + describe 'when no modal is open', -> it 'does nothing and allows the event chain to continue', asyncSpec (next) -> $link = affix('a[up-close]') # link is outside the modal up.hello($link) @@ -713,9 +714,24 @@ escapeEvent = $.Event('keydown', keyCode: 27) $('body').trigger(escapeEvent) next => expect(wasClosed).toBe(true) + + it 'stays open if #preventDefault() is called on up:modal:close event', asyncSpec (next) -> + up.modal.extract('.target', '<div class="target"><a up-close>text</a></div>', animation: false) + up.on 'up:modal:close', (e) -> e.preventDefault() + + next => + $backdrop = $('.up-modal-backdrop') + Trigger.clickSequence($backdrop) + + next => + expect(up.modal.isOpen()).toBe(true) + + # Since there isn't anyone who could handle the rejection inside + # the event handler, our handler mutes the rejection. + expect(window).not.toHaveUnhandledRejections() describe 'when opened with { closable: false }', -> it 'does not render a close icon', asyncSpec (next) -> up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)