UNPKG

redux-form

Version:

A higher order component decorator for forms using Redux and React

93 lines (89 loc) 2.1 kB
import { arrayRemoveAll } from '../actions'; var describeArrayRemoveAll = function describeArrayRemoveAll(reducer, expect, _ref) { var fromJS = _ref.fromJS; return function () { it('should do nothing with undefined', function () { var state = reducer(fromJS({ foo: { values: { myField: {} }, fields: { myField: {} } } }), arrayRemoveAll('foo', 'myField.subField')); expect(state).toEqualMap({ foo: { values: { myField: {} }, fields: { myField: {} } } }); }); it('should do nothing if already empty', function () { var state = reducer(fromJS({ foo: { values: { myField: { subField: [] } }, fields: { myField: { subField: [] } } } }), arrayRemoveAll('foo', 'myField.subField')); expect(state).toEqualMap({ foo: { values: { myField: { subField: [] } }, fields: { myField: { subField: [] } } } }); }); it('should remove all the elements', function () { var state = reducer(fromJS({ foo: { values: { myField: { subField: ['a', 'b', 'c', 'd'] } }, fields: { myField: { subField: [{ touched: true, visited: true }, { touched: true }, { touched: true, visited: true }, { touched: true }] } } } }), arrayRemoveAll('foo', 'myField.subField', 1)); expect(state).toEqualMap({ foo: { values: { myField: { subField: [] } }, fields: { myField: { subField: [] } } } }); }); }; }; export default describeArrayRemoveAll;