|
| 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, magnify; |
| 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":"/images/sample.jpg", |
| 32 | + "img":"/images/sample.jpg", |
| 33 | + "full":"/images/sample.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 productMediaDiv = document.createElement('div'); |
| 53 | + productMediaDiv.className = 'product media'; |
| 54 | + |
| 55 | + let mainDiv = document.createElement('div'); |
| 56 | + mainDiv.id = 'gallery_placeholder'; |
| 57 | + mainDiv.className = 'gallery-placeholder'; |
| 58 | + mainDiv.setAttribute('data-gallery-role', 'gallery-placeholder'); |
| 59 | + |
| 60 | + let img = document.createElement('img'); |
| 61 | + img.alt = 'main product photo'; |
| 62 | + img.id = 'main_product_photo'; |
| 63 | + img.className = 'gallery-placeholder__image'; |
| 64 | + img.src = '/images/sample.jpg'; |
| 65 | + mainDiv.appendChild(img); |
| 66 | + productMediaDiv.appendChild(mainDiv); |
| 67 | + document.body.appendChild(productMediaDiv); |
| 68 | + |
| 69 | + magnify = new Magnify(options, $('#gallery_placeholder')); |
| 70 | + gallery = new Gallery(options, $('#gallery_placeholder')); |
| 71 | + expect(gallery.settings.fullscreenConfig).toBeDefined(); |
| 72 | + expect(gallery.settings.fotoramaApi).toBeDefined(); |
| 73 | + expect(gallery.settings.data).toBeDefined(); |
| 74 | + expect(gallery.settings.api).toBeDefined(); |
| 75 | + |
| 76 | + gallery.openFullScreen(); |
| 77 | + |
| 78 | + console.log($('.fotorama__img--full')); //this should be available |
| 79 | + //console.log($._data($('.fotorama__img--full')[0], "events")); |
| 80 | + }); |
| 81 | + }); |
| 82 | + }); |
| 83 | +}); |
0 commit comments