Skip to content

Commit 84c6017

Browse files
committed
Merge branch 'MC-6354' into 'MC-18821'
MC-18821: Increase test coverage for Catalog functional area See merge request magn-m23/magn-m23!1706
2 parents e1bb637 + 68d18eb commit 84c6017

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ define([
99
], function ($, SwatchRenderer) {
1010
'use strict';
1111

12-
describe('Testing SwatchRenderer Widget', function () {
12+
describe('Testing "_RenderSwatchOptions" method of SwatchRenderer Widget', function () {
1313
var widget,
14+
html,
15+
optionConfig,
1416
attribute,
1517
optionId = 2,
1618
swathImageHeight = '60',
@@ -22,11 +24,21 @@ define([
2224
widget = new SwatchRenderer();
2325
attribute = {
2426
id: 1,
25-
options: [{id: optionId}]
27+
options: [{
28+
id: optionId
29+
}]
2630
};
2731
widget.options = {
28-
classes: {optionClass: "swatch-option"},
29-
jsonSwatchConfig: {1: {2: {type: 2}}},
32+
classes: {
33+
optionClass: 'swatch-option'
34+
},
35+
jsonSwatchConfig: {
36+
1: {
37+
2: {
38+
type: 2
39+
}
40+
}
41+
},
3042
jsonSwatchImageSizeConfig: {
3143
swatchImage: {
3244
width: swathImageWidth,
@@ -38,39 +50,31 @@ define([
3850
}
3951
}
4052
};
53+
optionConfig = widget.options.jsonSwatchConfig[attribute.id];
54+
html = $(widget._RenderSwatchOptions(attribute, 'option-label-control-id-1'))[0];
4155
});
4256

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 if swatch config has attribute id', function () {
53-
expect(widget.options.jsonSwatchConfig.hasOwnProperty(attribute.id)).toEqual(true);
54-
});
57+
it('check if swatch config has attribute id', function () {
58+
expect(widget.options.jsonSwatchConfig.hasOwnProperty(attribute.id)).toEqual(true);
59+
});
5560

56-
it('check if option config has option id', function () {
57-
expect(optionConfig.hasOwnProperty(optionId)).toEqual(true);
58-
});
61+
it('check if option config has option id', function () {
62+
expect(optionConfig.hasOwnProperty(optionId)).toEqual(true);
63+
});
5964

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-
});
65+
it('check swatch thumbnail image height attribute', function () {
66+
expect(html.hasAttribute('thumb-height')).toBe(true);
67+
expect(html.getAttribute('thumb-height')).toEqual(swathThumbImageHeight);
68+
});
6469

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-
});
70+
it('check swatch thumbnail image width attribute', function () {
71+
expect(html.hasAttribute('thumb-width')).toBe(true);
72+
expect(html.getAttribute('thumb-width')).toEqual(swathThumbImageWidth);
73+
});
6974

70-
it('check swatch image styles', function () {
71-
expect(html.style.height).toEqual(swathImageHeight + 'px');
72-
expect(html.style.width).toEqual(swathImageWidth + 'px');
73-
});
75+
it('check swatch image styles', function () {
76+
expect(html.style.height).toEqual(swathImageHeight + 'px');
77+
expect(html.style.width).toEqual(swathImageWidth + 'px');
7478
});
7579
});
7680
});

0 commit comments

Comments
 (0)