|
| 1 | +/************************* |
| 2 | + * |
| 3 | + * Copyright 2024 Adobe |
| 4 | + * All Rights Reserved. |
| 5 | + * |
| 6 | + * *********************** |
| 7 | + */ |
| 8 | + |
| 9 | +/*eslint max-nested-callbacks: 0*/ |
| 10 | +define(['magnifier/magnify', 'mage/gallery/gallery', 'jquery'], function (Magnify, Gallery, $) { |
| 11 | + 'use strict'; |
| 12 | + |
| 13 | + describe('magnifier/magnify', function () { |
| 14 | + var gallery, options; |
| 15 | + |
| 16 | + beforeEach(function () { |
| 17 | + options = { |
| 18 | + options: { |
| 19 | + 'nav':'thumbs','loop':true,'keyboard':true,'arrows':true,'allowfullscreen':true, |
| 20 | + 'showCaption':false,'width':700,'thumbwidth':88,'thumbheight':110,'height':700, |
| 21 | + 'transitionduration':500,'transition':'slide','navarrows':true,'navtype':'slides', |
| 22 | + 'navdir':'horizontal','whiteBorders':1 |
| 23 | + }, |
| 24 | + fullscreen: { |
| 25 | + 'nav':'thumbs','loop':true,'navdir':'horizontal','navarrows':false,'navtype':'slides', |
| 26 | + 'arrows':true,'showCaption':false,'transitionduration':500,'transition':'slide','whiteBorders':1 |
| 27 | + }, |
| 28 | + breakpoints: {'mobile':{'conditions':{'max-width':'767px'},'options':{'options':{'nav':'dots'}}}}, |
| 29 | + data: [ |
| 30 | + { |
| 31 | + 'thumb':'dev/tests/acceptance/tests/_data/adobe-base.jpg', |
| 32 | + 'img':'dev/tests/acceptance/tests/_data/adobe-base.jpg', |
| 33 | + 'full':'dev/tests/acceptance/tests/_data/adobe-base.jpg', |
| 34 | + 'caption':'simple1','position':'0','isMain':false,'type':'image','videoUrl':null |
| 35 | + } |
| 36 | + ], |
| 37 | + magnifierOpts: { |
| 38 | + 'fullscreenzoom':'20', |
| 39 | + 'top':'', |
| 40 | + 'left':'', |
| 41 | + 'width':'', |
| 42 | + 'height':'', |
| 43 | + 'eventType':'hover', |
| 44 | + 'enabled':false, |
| 45 | + 'mode':'outside' |
| 46 | + } |
| 47 | + }; |
| 48 | + }); |
| 49 | + |
| 50 | + describe('test magnifierFullscreen method', function () { |
| 51 | + it('Check if the current image has event handlers set for tap and double tap', function () { |
| 52 | + let pageWrapperDiv, productMediaDiv, mainDiv, img, activeImage, imageEvents; |
| 53 | + |
| 54 | + pageWrapperDiv = document.createElement('div'); |
| 55 | + pageWrapperDiv.className = 'page-wrapper'; |
| 56 | + |
| 57 | + productMediaDiv = document.createElement('div'); |
| 58 | + productMediaDiv.className = 'product media'; |
| 59 | + |
| 60 | + mainDiv = document.createElement('div'); |
| 61 | + mainDiv.id = 'gallery_placeholder'; |
| 62 | + mainDiv.className = 'gallery-placeholder _block-content-loading'; |
| 63 | + mainDiv.setAttribute('data-gallery-role', 'gallery-placeholder'); |
| 64 | + |
| 65 | + img = document.createElement('img'); |
| 66 | + img.alt = 'main product photo'; |
| 67 | + img.id = 'main_product_photo'; |
| 68 | + img.className = 'gallery-placeholder__image'; |
| 69 | + img.src = 'dev/tests/acceptance/tests/_data/adobe-base.jpg'; |
| 70 | + |
| 71 | + mainDiv.appendChild(img); |
| 72 | + pageWrapperDiv.appendChild(productMediaDiv); |
| 73 | + productMediaDiv.appendChild(mainDiv); |
| 74 | + document.body.appendChild(pageWrapperDiv); |
| 75 | + |
| 76 | + new Magnify(options, $('#gallery_placeholder')); |
| 77 | + gallery = new Gallery(options, $('#gallery_placeholder')); |
| 78 | + |
| 79 | + activeImage = document.createElement('img'); |
| 80 | + activeImage.className = 'fotorama__img--full'; |
| 81 | + $('[data-gallery-role="stage-shaft"] [data-active="true"]').append(activeImage); |
| 82 | + |
| 83 | + gallery.openFullScreen(); |
| 84 | + |
| 85 | + imageEvents = $._data($('.fotorama__img--full')[0], 'events'); |
| 86 | + expect(imageEvents).toBeInstanceOf(Object); |
| 87 | + expect(Object.getOwnPropertyNames(imageEvents)).toContain('touchend'); |
| 88 | + }); |
| 89 | + }); |
| 90 | + }); |
| 91 | +}); |
0 commit comments