Skip to content

Commit 4ace1e6

Browse files
committed
cover changes with jasmine test
1 parent 03ef933 commit 4ace1e6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,37 @@ define([
9898
widget._UpdatePrice();
9999
expect(productPriceMock.find().find.calls.count()).toBe(1);
100100
});
101+
102+
it('check getSelectedOptionPriceIndex', function () {
103+
var optionMock = '<div class="swatch-attribute" attribute-id="2" option-selected="4"></div>',
104+
element = $('<div class="' + widget.options.tooltipClass +
105+
'"><div class="image"></div><div class="title"></div><div class="corner"></div>' +
106+
optionMock + '</div>'
107+
),
108+
optionPricesMock = {
109+
optionPrices: {
110+
p: {
111+
finalPrice: {
112+
amount: 12
113+
}
114+
}
115+
}
116+
};
117+
118+
widget.element = element;
119+
widget.options.classes.attributeClass = 'swatch-attribute';
120+
widget.options.jsonConfig = optionPricesMock;
121+
widget.optionsMap = {
122+
2: {
123+
4: {
124+
products: 'p'
125+
},
126+
hasOwnProperty: jasmine.createSpy().and.returnValue(true)
127+
},
128+
hasOwnProperty: jasmine.createSpy().and.returnValue(true)
129+
};
130+
131+
expect(widget._getSelectedOptionPriceIndex()).toBe('p');
132+
});
101133
});
102134
});

0 commit comments

Comments
 (0)