specs: fix disabling jQuery animations during tests

This commit is contained in:
Pierre de La Morinerie 2018-08-01 09:39:47 +00:00
parent 8d9b65e556
commit b7382375e2
5 changed files with 14 additions and 11 deletions

View file

@ -5,7 +5,8 @@ module.exports = {
sourceType: 'module' sourceType: 'module'
}, },
globals: { globals: {
'$': true '$': true,
'process': true
}, },
plugins: ['prettier'], plugins: ['prettier'],
extends: ['eslint:recommended', 'prettier'], extends: ['eslint:recommended', 'prettier'],

View file

@ -18,8 +18,14 @@ Rails.start();
Turbolinks.start(); Turbolinks.start();
ActiveStorage.start(); ActiveStorage.start();
// Disable jQuery-driven animations during tests
if (process.env['RAILS_ENV'] === 'test') {
jQuery.fx.off = true;
}
// Expose globals // Expose globals
window.Bloodhound = Bloodhound; window.Bloodhound = Bloodhound;
window.Chartkick = Chartkick; window.Chartkick = Chartkick;
// Export jQuery globally for legacy Javascript files used in the old design
window.$ = jQuery; window.$ = jQuery;
window.jQuery = jQuery; window.jQuery = jQuery;

View file

@ -4,6 +4,7 @@ import * as ActiveStorage from 'activestorage';
import Chartkick from 'chartkick'; import Chartkick from 'chartkick';
import Highcharts from 'highcharts'; import Highcharts from 'highcharts';
import jQuery from 'jquery';
import 'select2'; import 'select2';
import 'typeahead.js'; import 'typeahead.js';
@ -45,6 +46,11 @@ Rails.start();
Turbolinks.start(); Turbolinks.start();
ActiveStorage.start(); ActiveStorage.start();
// Disable jQuery-driven animations during tests
if (process.env['RAILS_ENV'] === 'test') {
jQuery.fx.off = true;
}
// Expose globals // Expose globals
window.DS = window.DS || DS; window.DS = window.DS || DS;
window.Chartkick = Chartkick; window.Chartkick = Chartkick;

View file

@ -14,7 +14,6 @@
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload" = stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
= javascript_pack_tag 'application-old', defer: true, 'data-turbolinks-track': 'reload' = javascript_pack_tag 'application-old', defer: true, 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload' = javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
= csrf_meta_tags = csrf_meta_tags
:javascript :javascript
@ -26,14 +25,8 @@
#beta #beta
Env Test Env Test
- if Rails.env == 'test'
%script{ type: 'text/javascript' }
(typeof jQuery !== 'undefined') && (jQuery.fx.off = true);
= render partial: 'layouts/ie_lt_10' = render partial: 'layouts/ie_lt_10'
#wrap #wrap
.row .row
#header.navbar #header.navbar

View file

@ -44,6 +44,3 @@
= javascript_include_tag :xray = javascript_include_tag :xray
= yield :charts_js = yield :charts_js
- if Rails.env == "test"
%script{ type: "text/javascript" }
(typeof jQuery !== "undefined") && (jQuery.fx.off = true);