diff --git a/app/assets/javascripts/miq_flash.js b/app/assets/javascripts/miq_flash.js index 5a0e6ee899c3..9537a734bd45 100644 --- a/app/assets/javascripts/miq_flash.js +++ b/app/assets/javascripts/miq_flash.js @@ -1,6 +1,6 @@ // add a flash message to an existing #flash_msg_div // levels are error, warning, info, success -function add_flash(msg, level, options) { +window.add_flash = function(msg, level, options) { level = level || 'success'; options = options || {}; var cls = { alert: '', icon: '' }; @@ -68,7 +68,7 @@ function add_flash(msg, level, options) { } } -function clearFlash() { +window.clearFlash = function() { $('#flash_msg_div').empty(); } diff --git a/app/javascript/spec/helpers/old_js_file_require_helper.js b/app/javascript/spec/helpers/old_js_file_require_helper.js index a0968c3a7d2f..8521c1c508de 100644 --- a/app/javascript/spec/helpers/old_js_file_require_helper.js +++ b/app/javascript/spec/helpers/old_js_file_require_helper.js @@ -1,2 +1,4 @@ global.window = global; require('../../../assets/javascripts/miq_application.js'); +require('../../../assets/javascripts/miq_flash.js'); + diff --git a/app/javascript/spec/helpers/set_fixtures_helper.js b/app/javascript/spec/helpers/set_fixtures_helper.js new file mode 100644 index 000000000000..0d46501b91b6 --- /dev/null +++ b/app/javascript/spec/helpers/set_fixtures_helper.js @@ -0,0 +1,4 @@ +global.window = global; +window.setFixtures = function(html) { + $('html').html(html); +}; diff --git a/spec/javascripts/miq_flash_spec.js b/app/javascript/spec/old_js/miq_flash.spec.js similarity index 84% rename from spec/javascripts/miq_flash_spec.js rename to app/javascript/spec/old_js/miq_flash.spec.js index 00052dcef289..6a286c74945d 100644 --- a/spec/javascripts/miq_flash_spec.js +++ b/app/javascript/spec/old_js/miq_flash.spec.js @@ -1,29 +1,32 @@ -describe('miq_flash.js', function() { - describe('clearFlash', function() { - beforeEach(function() { +require('../helpers/set_fixtures_helper.js'); +require('../helpers/old_js_file_require_helper.js'); + +describe('miq_flash.js', () => { + describe('clearFlash', () => { + beforeEach(() => { var html = '