import FakeDom from '../../helpers/FakeDom'; jest.setTimeout(2000); describe('Original AJAX Framework library', function () { it('can get data from the current form and a series of parent forms', function (done) { FakeDom .new() .addScript([ 'modules/backend/assets/js/vendor/jquery.min.js', 'modules/system/assets/js/framework.js', ]) .render( '
' + '' + '' ) .then( (dom) => { const parentDataSpy = jest.spyOn(dom.window.jQuery.fn, 'getRequestParentData'); jest.spyOn(dom.window, 'alert').mockImplementation(() => {}); jest.spyOn(dom.window.jQuery, 'ajax').mockImplementation(() => { expect(parentDataSpy.mock.results[0].value).toMatchObject({ 'formOne': 'valueOne', 'fieldOne': 'overrideTwo', 'fieldFive': 'valueFive', 'formTwo': 'valueTwo', 'fieldTwo': 'valueTwo', 'fieldThree': 'valueThree', 'fieldFour': 'valueFour', 'multiField[]': 'multiThree', 'multiFieldTwo[]': ['multiOne', 'multiTwo'], }); done(); return dom.window.jQuery.Deferred(); }); dom.window.jQuery('#childForm').trigger('submit'); } ); }); });