|
| 1 | +/** |
| 2 | + * Copyright © 2013-2017 Magento, Inc. All rights reserved. |
| 3 | + * See COPYING.txt for license details. |
| 4 | + */ |
| 5 | + |
| 6 | +/* eslint max-nested-callbacks: 0 */ |
| 7 | +define([ |
| 8 | + 'squire' |
| 9 | +], function (Squire) { |
| 10 | + 'use strict'; |
| 11 | + |
| 12 | + var injector = new Squire(), |
| 13 | + mocks = { |
| 14 | + 'Magento_Ui/js/lib/core/events': { |
| 15 | + on: jasmine.createSpy() |
| 16 | + }, |
| 17 | + 'Magento_Ui/js/lib/registry/registry': { |
| 18 | + get: function() { |
| 19 | + return { |
| 20 | + get: jasmine.createSpy(), |
| 21 | + set: jasmine.createSpy() |
| 22 | + }; |
| 23 | + }, |
| 24 | + create: jasmine.createSpy(), |
| 25 | + set: jasmine.createSpy(), |
| 26 | + async: jasmine.createSpy() |
| 27 | + }, |
| 28 | + '/mage/utils/wrapper': jasmine.createSpy() |
| 29 | + }, |
| 30 | + obj, |
| 31 | + dataScope = 'dataScope'; |
| 32 | + |
| 33 | + beforeEach(function (done) { |
| 34 | + injector.mock(mocks); |
| 35 | + injector.require(['Magento_Ui/js/form/element/multiselect'], function (Constr) { |
| 36 | + obj = new Constr({ |
| 37 | + provider: 'provName', |
| 38 | + name: '', |
| 39 | + index: '', |
| 40 | + dataScope: dataScope |
| 41 | + }); |
| 42 | + |
| 43 | + done(); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + describe('Magento_Ui/js/form/element/multiselect', function () { |
| 48 | + describe('"setPrepareToSendData" method', function () { |
| 49 | + it('Check method call with empty array as parameter.', function () { |
| 50 | + expect(obj.setPrepareToSendData([])).toBeUndefined(); |
| 51 | + expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ''); |
| 52 | + }); |
| 53 | + |
| 54 | + it('Check method call with array with data as parameter.', function () { |
| 55 | + expect(obj.setPrepareToSendData(['1', '2', '3'])).toBeUndefined(); |
| 56 | + expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ['1', '2', '3']); |
| 57 | + }); |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
0 commit comments