2017-01-06 19:19:42 -05:00
|
|
|
// enable test fixtures
|
2016-12-29 16:42:48 -05:00
|
|
|
require('jasmine-jquery');
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-01-06 19:19:42 -05:00
|
|
|
jasmine.getFixtures().fixturesPath = 'base/spec/javascripts/fixtures';
|
|
|
|
jasmine.getJSONFixtures().fixturesPath = 'base/spec/javascripts/fixtures';
|
|
|
|
|
2017-01-06 16:44:03 -05:00
|
|
|
// include common libraries
|
|
|
|
window.$ = window.jQuery = require('jquery');
|
|
|
|
window._ = require('underscore');
|
2017-02-06 01:57:44 -05:00
|
|
|
window.Cookies = require('js-cookie');
|
2017-01-06 18:30:54 -05:00
|
|
|
window.Vue = require('vue');
|
|
|
|
window.Vue.use(require('vue-resource'));
|
|
|
|
require('jquery-ujs');
|
2017-01-06 16:44:03 -05:00
|
|
|
require('bootstrap/js/affix');
|
|
|
|
require('bootstrap/js/alert');
|
|
|
|
require('bootstrap/js/button');
|
|
|
|
require('bootstrap/js/collapse');
|
|
|
|
require('bootstrap/js/dropdown');
|
|
|
|
require('bootstrap/js/modal');
|
|
|
|
require('bootstrap/js/scrollspy');
|
|
|
|
require('bootstrap/js/tab');
|
|
|
|
require('bootstrap/js/transition');
|
|
|
|
require('bootstrap/js/tooltip');
|
|
|
|
require('bootstrap/js/popover');
|
|
|
|
|
|
|
|
// stub expected globals
|
2016-11-19 16:59:32 -05:00
|
|
|
window.gl = window.gl || {};
|
2016-12-30 19:14:33 -05:00
|
|
|
window.gl.TEST_HOST = 'http://test.host';
|
|
|
|
window.gon = window.gon || {};
|
2017-01-06 19:19:42 -05:00
|
|
|
|
|
|
|
// render all of our tests
|
|
|
|
const testsContext = require.context('.', true, /_spec$/);
|
|
|
|
testsContext.keys().forEach(function (path) {
|
|
|
|
try {
|
|
|
|
testsContext(path);
|
|
|
|
} catch (err) {
|
2017-02-07 12:41:29 -05:00
|
|
|
console.error('[ERROR] Unable to load spec: ', path);
|
|
|
|
describe('Test bundle', function () {
|
|
|
|
it(`includes '${path}'`, function () {
|
|
|
|
expect(err).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
2017-01-06 19:19:42 -05:00
|
|
|
}
|
|
|
|
});
|
2017-02-10 18:45:54 -05:00
|
|
|
|
|
|
|
// workaround: include all source files to find files with 0% coverage
|
|
|
|
// see also https://github.com/deepsweet/istanbul-instrumenter-loader/issues/15
|
|
|
|
describe('Uncovered files', function () {
|
|
|
|
// the following files throw errors because of undefined variables
|
|
|
|
const troubleMakers = [
|
|
|
|
'./blob_edit/blob_edit_bundle.js',
|
|
|
|
'./cycle_analytics/components/stage_plan_component.js',
|
|
|
|
'./cycle_analytics/components/stage_staging_component.js',
|
|
|
|
'./cycle_analytics/components/stage_test_component.js',
|
|
|
|
'./diff_notes/components/jump_to_discussion.js',
|
|
|
|
'./diff_notes/components/resolve_count.js',
|
|
|
|
'./merge_conflicts/components/inline_conflict_lines.js',
|
|
|
|
'./merge_conflicts/components/parallel_conflict_lines.js',
|
|
|
|
'./network/branch_graph.js',
|
|
|
|
];
|
|
|
|
|
|
|
|
const sourceFiles = require.context('~', true, /^\.\/(?!application\.js).*\.(js|es6)$/);
|
|
|
|
sourceFiles.keys().forEach(function (path) {
|
|
|
|
// ignore if there is a matching spec file
|
|
|
|
if (testsContext.keys().indexOf(`${path.replace(/\.js(\.es6)?$/, '')}_spec`) > -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
it(`includes '${path}'`, function () {
|
|
|
|
try {
|
|
|
|
sourceFiles(path);
|
|
|
|
} catch (err) {
|
|
|
|
if (troubleMakers.indexOf(path) === -1) {
|
|
|
|
expect(err).toBeNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|