|
| 1 | +/** |
| 2 | + * Copyright © Magento, Inc. All rights reserved. |
| 3 | + * See COPYING.txt for license details. |
| 4 | + */ |
| 5 | + |
| 6 | +/* eslint-disable max-nested-callbacks */ |
| 7 | +define([ |
| 8 | + 'jquery', |
| 9 | + 'Magento_ConfigurableProduct/js/components/dynamic-rows-configurable', |
| 10 | + 'Magento_Ui/js/dynamic-rows/dynamic-rows' |
| 11 | +], function ($, DynamicRowsConf, DynamicRows) { |
| 12 | + 'use strict'; |
| 13 | + |
| 14 | + describe('Magento_ConfigurableProduct/js/components/dynamic-rows-configurable', function () { |
| 15 | + var model; |
| 16 | + |
| 17 | + beforeEach(function () { |
| 18 | + model = new DynamicRowsConf(new DynamicRows({ |
| 19 | + isEmpty: jasmine.createSpy().and.returnValue(1), |
| 20 | + isShowAddProductButton: jasmine.createSpy().and.returnValue(1) |
| 21 | + })); |
| 22 | + |
| 23 | + }); |
| 24 | + |
| 25 | + it('Verify processingUnionInsertDat method', function () { |
| 26 | + var expectedData = [], |
| 27 | + mockData = [ |
| 28 | + { |
| 29 | + attributes: 'Color: dsfsd', |
| 30 | + sku: 'Conf-sdfs' |
| 31 | + }, |
| 32 | + { |
| 33 | + attributes: 'Color: sdfs', |
| 34 | + sku: 'Conf-dsfsd' |
| 35 | + } |
| 36 | + ], |
| 37 | + sourceMock = { |
| 38 | + get: jasmine.createSpy().and.returnValue(['code1', 'code2']), |
| 39 | + set: jasmine.createSpy().and.callFake(function (path, row) { |
| 40 | + expectedData.push(row); |
| 41 | + }) |
| 42 | + }; |
| 43 | + |
| 44 | + model.getChildItems = jasmine.createSpy().and.returnValue($('')); |
| 45 | + model.source = sourceMock; |
| 46 | + model.processingUnionInsertData(mockData); |
| 47 | + expect(model.source.get).toHaveBeenCalled(); |
| 48 | + expect(model.getChildItems).toHaveBeenCalled(); |
| 49 | + expect(expectedData[1].sku).toBe(mockData[0].sku); |
| 50 | + }); |
| 51 | + |
| 52 | + }); |
| 53 | +}); |
0 commit comments