Skip to content

Commit

Permalink
cover gallery.js with jasmine test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazar65 committed Jan 21, 2020
1 parent d74f73c commit 80b8514
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions dev/tests/js/jasmine/tests/lib/mage/gallery/gallery.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'mage/gallery/gallery',
'jquery'
], function (Gallery, $) {
'use strict';

var gallery,
options,
element;

beforeEach(function () {
options = {
options: {
allowfullscreen: true,
arrows: true,
height: 700,
keyboard: true,
loop: true,
nav: 'thumbs',
navarrows: true,
navdir: 'horizontal',
navtype: 'slides',
showCaption: false,
thumbheight: 110,
thumbwidth: 88,
transition: 'slide',
transitionduration: 500,
width: 700
},
fullscreen: {
arrows: true,
loop: true,
nav: 'thumbs',
navarrows: false,
navdir: 'horizontal',
navtype: 'slides',
showCaption: false,
transition: 'slide',
transitionduration: 500
},
breakpoints: {
mobile: {}
},
data: [
{
caption: 'Simple product',
isMain: true,
position: '1',
type: 'image',
videoUrl: null,
thumb: '',
full: '',
img: ''
}
],
magnifierOpts: {
enabled: false,
eventType: 'hover',
fullscreenzoom: '20',
height: 100,
largeWrapper: '[data-gallery-role=\'magnifier\']',
left: 10,
mode: 'outside',
thumb: '.fotorama__img',
top: 10,
width: 100,
zoomable: false
}
};
element = $('<div class="gallery-placeholder' +
' _block-content-loading" data-gallery-role="gallery-placeholder">' +
'<img alt="main product photo" class="gallery-placeholder__image" src="">' +
'</div>');

spyOn($.fn, 'data').and.callFake(function () {
return {
setOptions: jasmine.createSpy().and.returnValue(true),
updateOptions: jasmine.createSpy().and.returnValue(true)
};
});
expect();
gallery = new Gallery(options, element);

});

describe('"initGallery" method', function () {
it('Verify gallery initialization', function () {
expect(gallery.settings.$elementF.class).toBe(element[1]);
expect(gallery.settings.fullscreenConfig).toBeDefined();
expect(gallery.settings.fotoramaApi).toBeDefined();
expect(gallery.settings.data).toBeDefined();
expect(gallery.settings.api).toBeDefined();
});
});
});

0 comments on commit 80b8514

Please sign in to comment.