Add very basic shim of I18n for unit testing

As I18n.js is now provided outside of webpack, we could include the
full version through webpack again (risking incompatible version).

Since we don't use actual translations, I argue it's better to shim the
external I18n object just for karma.
pull/4648/head
Oliver Günther 8 years ago
parent 561ec0c88c
commit 3da1446eee
  1. 4
      frontend/karma.conf.js
  2. 38
      frontend/tests/unit/lib/i18n-js.shim.js

@ -48,6 +48,10 @@ module.exports = function (config) {
// list of files / patterns to load in the browser
files: [
// I18n.js is provided by the Asset pipeline,
// which is unavailable for unit tests.
// For testing, shim its functionality
'tests/unit/lib/i18n-js.shim.js',
'../app/assets/javascripts/bundles/openproject-global.css',
'../app/assets/javascripts/bundles/openproject-global.js',

@ -0,0 +1,38 @@
//-- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
var I18n = {
t: function(key) {
return '[missing "' + key + '" translation]';
},
defaultLocale: 'en',
locale: 'en',
translations: {
en: {}
}
};
Loading…
Cancel
Save