Skip to content

Commit 753b922

Browse files
committed
MC-18821: Increase test coverage for Catalog functional area
- Jasmine test for MC-6354
1 parent cc23756 commit 753b922

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'Magento_Swatches/js/swatch-renderer'
9+
], function ($, SwatchRenderer) {
10+
'use strict';
11+
12+
describe('Testing SwatchRenderer Widget', function () {
13+
var widget,
14+
attribute,
15+
optionId = 2,
16+
swathImageHeight = '60',
17+
swathImageWidth = '70',
18+
swathThumbImageHeight = '40',
19+
swathThumbImageWidth = '50';
20+
21+
beforeEach(function () {
22+
widget = new SwatchRenderer();
23+
attribute = {
24+
id: 1,
25+
options: [{id: optionId}]
26+
};
27+
widget.options = {
28+
classes: {optionClass: "swatch-option"},
29+
jsonSwatchConfig: {1: {2: {type: 2}}},
30+
jsonSwatchImageSizeConfig: {
31+
swatchImage: {
32+
width: swathImageWidth,
33+
height: swathImageHeight
34+
},
35+
swatchThumb: {
36+
width: swathThumbImageWidth,
37+
height: swathThumbImageHeight
38+
}
39+
}
40+
};
41+
});
42+
43+
describe('"_RenderSwatchOptions" method', function () {
44+
var html,
45+
optionConfig;
46+
47+
beforeEach(function () {
48+
optionConfig = widget.options.jsonSwatchConfig[attribute.id];
49+
html = $(widget._RenderSwatchOptions(attribute, 'option-label-control-id-1'))[0];
50+
});
51+
52+
it('check first conditional statement', function () {
53+
expect(widget.options.jsonSwatchConfig.hasOwnProperty(attribute.id)).toEqual(true);
54+
});
55+
56+
it('check second conditional statement', function () {
57+
expect(optionConfig.hasOwnProperty(optionId)).toEqual(true);
58+
});
59+
60+
it('check swatch thumbnail image height attribute', function () {
61+
expect(html.hasAttribute('thumb-height')).toBe(true);
62+
expect(html.getAttribute('thumb-height')).toEqual(swathThumbImageHeight);
63+
});
64+
65+
it('check swatch thumbnail image width attribute', function () {
66+
expect(html.hasAttribute('thumb-width')).toBe(true);
67+
expect(html.getAttribute('thumb-width')).toEqual(swathThumbImageWidth);
68+
});
69+
70+
it('check swatch image styles', function () {
71+
expect(html.style.height).toEqual(swathImageHeight + 'px');
72+
expect(html.style.width).toEqual(swathImageWidth + 'px');
73+
});
74+
});
75+
});
76+
});

0 commit comments

Comments
 (0)