Skip to content

Commit

Permalink
ENGCOM-6285: The image details are not hidden when click on same image
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirZaets authored Nov 25, 2019
2 parents 72da0b2 + 63fea91 commit 84647d8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ define([
show: function (record) {
var img;

if (record._rowIndex === this.visibleRecord()) {
this.hide();

return;
}

this.hide();
this.displayedRecord(record);
this._selectRow(record.rowNumber || null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/* eslint-disable max-nested-callbacks, no-undef */

define([
'Magento_Ui/js/grid/columns/image-preview',
'ko',
'jquery'
], function (Preview, ko, $) {
'use strict';

describe('Ui/js/grid/columns/image-preview', function () {
var record = {
_rowIndex: 1,
rowNumber: 1
},
imagePreview;

beforeEach(function () {
imagePreview = new Preview();

/**
* @return {Object}
*/
function getThumbnail() {
return {
previewRowId: ko.observable()
};
}

imagePreview.thumbnailComponent = getThumbnail;

imagePreview.visibleRecord = ko.observable(1);
});

describe('show method', function () {
it('show image', function () {
var mockImg = document.createElement('img'),
hide = spyOn(imagePreview, 'hide');

spyOn($.fn, 'get').and.returnValue(mockImg);
imagePreview.show(record);
expect(hide).toHaveBeenCalledTimes(1);
});

});
});
});

0 comments on commit 84647d8

Please sign in to comment.