Skip to content

Commit e5d143d

Browse files
committed
Cover changes with jasmnine test
1 parent a7ffbd6 commit e5d143d

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
/* eslint-disable max-nested-callbacks, no-undef */
6+
7+
define([
8+
'Magento_Ui/js/grid/columns/image-preview',
9+
'ko',
10+
'jquery'
11+
], function (Preview, ko, $) {
12+
'use strict';
13+
14+
describe('Ui/js/grid/columns/image-preview', function () {
15+
var record = {
16+
_rowIndex: 1,
17+
rowNumber: 1
18+
},
19+
imagePreview;
20+
21+
beforeEach(function () {
22+
imagePreview = new Preview();
23+
24+
/**
25+
* @return {Object}
26+
*/
27+
function getThumbnail() {
28+
return {
29+
previewRowId: ko.observable()
30+
};
31+
}
32+
33+
imagePreview.thumbnailComponent = getThumbnail;
34+
35+
imagePreview.visibleRecord = ko.observable(1);
36+
});
37+
38+
describe('show method', function () {
39+
it('show image', function () {
40+
var mockImg = document.createElement('img'),
41+
hide = spyOn(imagePreview, 'hide');
42+
43+
spyOn($.fn, 'get').and.returnValue(mockImg);
44+
imagePreview.show(record);
45+
expect(hide).toHaveBeenCalledTimes(1);
46+
});
47+
48+
});
49+
});
50+
});

0 commit comments

Comments
 (0)