Skip to content

Commit c5991d3

Browse files
committed
Refactoring test to remove object after test
1 parent 80b8514 commit c5991d3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

dev/tests/js/jasmine/tests/lib/mage/gallery/gallery.test.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ define([
1111

1212
var gallery,
1313
options,
14-
element;
14+
element,
15+
jqueryDataMock,
16+
originSpy;
1517

1618
beforeEach(function () {
1719
options = {
@@ -76,25 +78,25 @@ define([
7678
' _block-content-loading" data-gallery-role="gallery-placeholder">' +
7779
'<img alt="main product photo" class="gallery-placeholder__image" src="">' +
7880
'</div>');
79-
80-
spyOn($.fn, 'data').and.callFake(function () {
81-
return {
82-
setOptions: jasmine.createSpy().and.returnValue(true),
83-
updateOptions: jasmine.createSpy().and.returnValue(true)
84-
};
85-
});
86-
expect();
87-
gallery = new Gallery(options, element);
88-
8981
});
9082

9183
describe('"initGallery" method', function () {
9284
it('Verify gallery initialization', function () {
85+
originSpy = $.fn.data;
86+
jqueryDataMock = {
87+
setOptions: jasmine.createSpy().and.returnValue(true),
88+
updateOptions: jasmine.createSpy().and.returnValue(true)
89+
}
90+
spyOn($.fn, 'data').and.callFake(function () { return jqueryDataMock });
91+
92+
gallery = new Gallery(options, element);
9393
expect(gallery.settings.$elementF.class).toBe(element[1]);
9494
expect(gallery.settings.fullscreenConfig).toBeDefined();
9595
expect(gallery.settings.fotoramaApi).toBeDefined();
9696
expect(gallery.settings.data).toBeDefined();
9797
expect(gallery.settings.api).toBeDefined();
98+
99+
$.fn.data = originSpy;
98100
});
99101
});
100102
});

0 commit comments

Comments
 (0)