|
| 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(['Magento_Customer/js/form/components/insert-listing'], function (Constr) { |
| 8 | + 'use strict'; |
| 9 | + |
| 10 | + describe('Magento_Customer/js/form/components/insert-listing', function () { |
| 11 | + var obj, |
| 12 | + ids = ['1', '2'], |
| 13 | + data = { |
| 14 | + action: 'delete', |
| 15 | + data: { |
| 16 | + selected: ids |
| 17 | + } |
| 18 | + }; |
| 19 | + |
| 20 | + beforeEach(function () { |
| 21 | + obj = new Constr({}); |
| 22 | + }); |
| 23 | + |
| 24 | + describe('Check delete massaction process', function () { |
| 25 | + it('Check call to deleteMassaction method', function () { |
| 26 | + obj.deleteMassaction = { |
| 27 | + call: jasmine.createSpy() |
| 28 | + }; |
| 29 | + obj.onMassAction(data); |
| 30 | + |
| 31 | + expect(obj.deleteMassaction.call).toHaveBeenCalledWith(obj, { |
| 32 | + selected: ids |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + it('Check ids are retrieved from selections provider if they are NOT in data', function () { |
| 37 | + var selectionsProvider = { |
| 38 | + selected: jasmine.createSpy().and.returnValue(ids) |
| 39 | + }; |
| 40 | + |
| 41 | + obj.selections = function () { // jscs:ignore jsDoc |
| 42 | + return selectionsProvider; |
| 43 | + }; |
| 44 | + obj._delete = jasmine.createSpy(); |
| 45 | + obj.onMassAction({ |
| 46 | + action: 'delete', |
| 47 | + data: {} |
| 48 | + }); |
| 49 | + |
| 50 | + expect(selectionsProvider.selected).toHaveBeenCalled(); |
| 51 | + expect(obj._delete).toHaveBeenCalledWith([1, 2]); |
| 52 | + }); |
| 53 | + |
| 54 | + it('Check removal of default addresses', function () { |
| 55 | + obj.source = { |
| 56 | + get: jasmine.createSpy().and.returnValues(2, 3), |
| 57 | + set: jasmine.createSpy() |
| 58 | + }; |
| 59 | + obj.onMassAction(data); |
| 60 | + |
| 61 | + expect(obj.source.get.calls.count()).toEqual(2); |
| 62 | + expect(obj.source.set.calls.count()).toEqual(1); |
| 63 | + }); |
| 64 | + }); |
| 65 | + }); |
| 66 | +}); |
0 commit comments