Skip to content

Commit 8ac2747

Browse files
committed
ACP2E-3504: added test coverage
1 parent 1cb1200 commit 8ac2747

File tree

3 files changed

+119
-2
lines changed

3 files changed

+119
-2
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
namespace Unit\ViewModel;
8+
9+
use Magento\ConfigurableProduct\ViewModel\UploadResizeConfigValue;
10+
use Magento\Backend\Model\Image\UploadResizeConfigInterface;
11+
use PHPUnit\Framework\TestCase;
12+
13+
class UploadResizeConfigValueTest extends TestCase
14+
{
15+
/**
16+
* @var UploadResizeConfigInterface|\PHPUnit\Framework\MockObject\MockObject
17+
*/
18+
private $uploadResizeConfigMock;
19+
20+
/**
21+
* @var UploadResizeConfigValue
22+
*/
23+
private $viewModel;
24+
25+
protected function setUp(): void
26+
{
27+
$this->uploadResizeConfigMock = $this->createMock(UploadResizeConfigInterface::class);
28+
$this->viewModel = new UploadResizeConfigValue($this->uploadResizeConfigMock);
29+
}
30+
31+
public function testGetMaxWidth()
32+
{
33+
$this->uploadResizeConfigMock->method('getMaxWidth')->willReturn(100);
34+
$this->assertEquals(100, $this->viewModel->getMaxWidth());
35+
}
36+
37+
public function testGetMaxHeight()
38+
{
39+
$this->uploadResizeConfigMock->method('getMaxHeight')->willReturn(200);
40+
$this->assertEquals(200, $this->viewModel->getMaxHeight());
41+
}
42+
43+
public function testIsResizeEnabled()
44+
{
45+
$this->uploadResizeConfigMock->method('isResizeEnabled')->willReturn(true);
46+
$this->assertTrue($this->viewModel->isResizeEnabled());
47+
}
48+
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2015 Adobe
3+
* All Rights Reserved.
44
*/
55

66
/* eslint-disable no-undef */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright 2025 Adobe
3+
* All Rights Reserved.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'Magento_ConfigurableProduct/js/variations/steps/bulk',
9+
'jquery',
10+
'ko',
11+
'underscore',
12+
'mage/template',
13+
'Magento_Ui/js/modal/alert',
14+
'Magento_Catalog/js/product-gallery',
15+
'jquery/uppy-core',
16+
'mage/translate'
17+
], function (Bulk, $) {
18+
describe('Magento_ConfigurableProduct/js/variations/steps/bulk', function () {
19+
let bulkInstance, config;
20+
21+
beforeEach(function () {
22+
config = {
23+
isResizeEnabled: true,
24+
maxWidth: 800,
25+
maxHeight: 600
26+
};
27+
bulkInstance = new Bulk(config);
28+
29+
window.FORM_KEY = 'mocked_form_key';
30+
});
31+
32+
describe('bindGalleries', function () {
33+
beforeEach(function () {
34+
spyOn($.fn, 'mage').and.returnValue({
35+
productGallery: jasmine.createSpy('productGallery')
36+
});
37+
spyOn($.fn, 'trigger');
38+
spyOn($.fn, 'data').and.returnValue(false);
39+
spyOn($.fn, 'find').and.returnValue($('<div></div>'));
40+
spyOn($.fn, 'on');
41+
spyOn($.fn, 'each').and.callFake(function (callback) {
42+
callback.call(this, 0, $('<div></div>'));
43+
});
44+
45+
window.Uppy = {
46+
Uppy: jasmine.createSpy('Uppy').and.returnValue({
47+
use: jasmine.createSpy('use'),
48+
on: jasmine.createSpy('on')
49+
}),
50+
Dashboard: jasmine.createSpy('Dashboard'),
51+
Compressor: jasmine.createSpy('Compressor'),
52+
DropTarget: jasmine.createSpy('DropTarget'),
53+
XHRUpload: jasmine.createSpy('XHRUpload')
54+
};
55+
});
56+
57+
it('should initialize galleries and Uppy', function () {
58+
bulkInstance.bindGalleries();
59+
60+
expect($.fn.mage).toHaveBeenCalledWith('productGallery', jasmine.any(Object));
61+
expect(window.Uppy.Uppy).toHaveBeenCalled();
62+
expect(window.Uppy.Uppy().use).toHaveBeenCalledWith(window.Uppy.Dashboard, jasmine.any(Object));
63+
expect(window.Uppy.Uppy().use).toHaveBeenCalledWith(window.Uppy.Compressor, jasmine.any(Object));
64+
expect(window.Uppy.Uppy().use).toHaveBeenCalledWith(window.Uppy.DropTarget, jasmine.any(Object));
65+
expect(window.Uppy.Uppy().use).toHaveBeenCalledWith(window.Uppy.XHRUpload, jasmine.any(Object));
66+
});
67+
});
68+
});
69+
});

0 commit comments

Comments
 (0)