spec_app/spec/javascripts/up/popup_spec.js.coffee in unpoly-rails-0.31.2 vs spec_app/spec/javascripts/up/popup_spec.js.coffee in unpoly-rails-0.32.0

- old
+ new

@@ -1,10 +1,10 @@ describe 'up.popup', -> u = up.util - describe 'Javascript functions', -> + describe 'JavaScript functions', -> describe 'up.popup.attach', -> beforeEach -> jasmine.addMatchers @@ -162,11 +162,11 @@ it 'opens the clicked link in a popup', -> @stubAttach() Trigger.click(@$link) expect(@attachSpy).toHaveBeenCalledWith(@$link) - # IE does not call Javascript and always performs the default action on right clicks + # IE does not call JavaScript and always performs the default action on right clicks unless navigator.userAgent.match(/Trident/) it 'does nothing if the right mouse button is used', -> @stubAttach() Trigger.click(@$link, button: 2) expect(@attachSpy).not.toHaveBeenCalled() @@ -226,11 +226,11 @@ it 'does nothing on click', -> Trigger.click(@$link) expect(@attachSpy).not.toHaveBeenCalled() - # IE does not call Javascript and always performs the default action on right clicks + # IE does not call JavaScript and always performs the default action on right clicks unless navigator.userAgent.match(/Trident/) it 'does nothing if the right mouse button is pressed down', -> Trigger.mousedown(@$link, button: 2) expect(@attachSpy).not.toHaveBeenCalled() @@ -271,9 +271,27 @@ $closer = $popup.affix('a[up-close]') # link is within the popup up.hello($closer) Trigger.clickSequence($closer) u.nextFrame -> expect(up.popup.isOpen()).toBe(false) + expect(backgroundClicked).not.toHaveBeenCalled() + done() + + describe 'when clicked inside a popup when a modal is open', -> + + it 'closes the popup, but not the modal', (done) -> + + up.modal.extract '.modalee', '<div class="modalee"></div>' + $modalee = $('.up-modal .modalee') + $opener = $modalee.affix('a') + up.popup.attach($opener, html: '<div class="popupee">text</div>', target: '.popupee') + $popupee = $('.up-popup .popupee') + $closer = $popupee.affix('a[up-close]') # link is within the popup + up.hello($closer) + Trigger.clickSequence($closer) + u.nextFrame -> + expect(up.popup.isOpen()).toBe(false) + expect(up.modal.isOpen()).toBe(true) expect(backgroundClicked).not.toHaveBeenCalled() done() describe 'when no popup is open', ->