diff --git a/app/assets/javascripts/miq_application.js b/app/assets/javascripts/miq_application.js index 2af47478ed27..688234cac93d 100644 --- a/app/assets/javascripts/miq_application.js +++ b/app/assets/javascripts/miq_application.js @@ -449,9 +449,9 @@ function miqResetSizeTimer() { } // Pass fields to server given a URL and fields in name/value pairs -function miqPassFields(url, args) { +window.miqPassFields = function (url, args) { return url + '?' + $.param(args); -} +}; function miqChartLinkData(col, row, value, category, series, id, message) { // Create the context menu diff --git a/app/javascript/spec/helpers/old_js_file_require_helper.js b/app/javascript/spec/helpers/old_js_file_require_helper.js new file mode 100644 index 000000000000..a0968c3a7d2f --- /dev/null +++ b/app/javascript/spec/helpers/old_js_file_require_helper.js @@ -0,0 +1,2 @@ +global.window = global; +require('../../../assets/javascripts/miq_application.js'); diff --git a/spec/javascripts/fields_spec.js b/app/javascript/spec/old_js/fields.spec.js similarity index 54% rename from spec/javascripts/fields_spec.js rename to app/javascript/spec/old_js/fields.spec.js index 89be1af4beaa..d583bc953a48 100644 --- a/spec/javascripts/fields_spec.js +++ b/app/javascript/spec/old_js/fields.spec.js @@ -1,5 +1,7 @@ -describe('Pass fields to server', function() { - it('returns url fields in name/value pairs', function() { +require('../helpers/old_js_file_require_helper.js'); + +describe('Pass fields to server', () => { + it('returns url fields in name/value pairs', () => { var url = '/path/to/infinity'; var args = {'foo': 'bar', 'lorem': 'ipsum'}; expect(miqPassFields(url, args)).toEqual('/path/to/infinity?foo=bar&lorem=ipsum'); diff --git a/spec/javascripts/miq_api_spec.js b/app/javascript/spec/old_js/miq_api.spec.js similarity index 69% rename from spec/javascripts/miq_api_spec.js rename to app/javascript/spec/old_js/miq_api.spec.js index bee95828425a..af25cf336c7c 100644 --- a/spec/javascripts/miq_api_spec.js +++ b/app/javascript/spec/old_js/miq_api.spec.js @@ -1,8 +1,8 @@ -describe('miq_api.js', function() { - it("can base64 encode utf8 passwords", function(done) { +describe('miq_api.js', () => { + it("can base64 encode utf8 passwords", done => { var getArgs; - spyOn(vanillaJsAPI, 'get').and.callFake(function(_url, args) { + jest.spyOn(vanillaJsAPI, 'get').mockImplementation(function(_url, args) { getArgs = args; return Promise.resolve({}); });