Skip to content

Commit af1b534

Browse files
committed
MAGETWO-91003: Border Color should be disabled when "Border" is selected None
Refactor colorpicker KO binding unit test
1 parent 3bed8a9 commit af1b534

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/ko/bind/color-picker.test.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ define([
2929

3030
describe('Colorpicker binding', function () {
3131
it('Should call spectrum on $input with disabled configuration if view model disabled', function () {
32-
var valueAccessor = jasmine.createSpy().and.returnValue({}),
32+
var value = {
33+
configStuffInHere: true
34+
},
35+
valueAccessor = jasmine.createSpy().and.returnValue(value),
3336
viewModel = {
3437
disabled: jasmine.createSpy().and.returnValue(true)
3538
};
@@ -39,9 +42,13 @@ define([
3942

4043
ko.bindingHandlers.colorPicker.init($input, valueAccessor, null, viewModel);
4144

42-
expect($.fn.spectrum).toHaveBeenCalledWith({
43-
disabled: true
44-
});
45+
expect(value.change).toEqual(jasmine.any(Function));
46+
expect(value.hide).toEqual(jasmine.any(Function));
47+
expect(value.show).toEqual(jasmine.any(Function));
48+
expect(value.change).toBe(value.hide);
49+
50+
expect($.fn.spectrum.calls.allArgs()).toEqual([[value], ['disable']]);
51+
expect(viewModel.disabled).toHaveBeenCalled();
4552

4653
$.fn.init = jasmine.createSpy().and.returnValue($.fn);
4754

@@ -69,7 +76,8 @@ define([
6976
expect(value.show).toEqual(jasmine.any(Function));
7077
expect(value.change).toBe(value.hide);
7178

72-
expect($.fn.spectrum).toHaveBeenCalledWith(value);
79+
expect($.fn.spectrum.calls.allArgs()).toEqual([[value], ['enable']]);
80+
expect(viewModel.disabled).toHaveBeenCalled();
7381

7482
$.fn.init = jasmine.createSpy().and.returnValue($.fn);
7583

0 commit comments

Comments
 (0)