diff --git a/test/unit-tests/common.js b/test/unit-tests/common.js index 169c3c3f83..2727b0f75b 100644 --- a/test/unit-tests/common.js +++ b/test/unit-tests/common.js @@ -33,8 +33,29 @@ // Include and setup all the stuff for testing define([ - 'chai' + 'chai', + 'backbone' ],function(chai) { window.expect = chai.expect; window.assert = chai.assert; + + // Components read a little ambient state at render time -- Button asks + // Common.UI.Scaling for the current ratio, and the menus ask Common.Locale + // for the text direction. Pulling in the real modules would drag 'core' and + // the whole application bootstrap into a unit test, so stub the two calls. + window.Common = window.Common || {}; + Common.UI = Common.UI || {}; + Common.UI.Scaling = Common.UI.Scaling || {}; + if (!Common.UI.Scaling.currentRatio) { + Common.UI.Scaling.currentRatio = function() { return 1; }; + } + Common.Locale = Common.Locale || {}; + if (!Common.Locale.isCurrentLanguageRtl) { + Common.Locale.isCurrentLanguageRtl = function() { return false; }; + } + // Components subscribe to app-wide events (uitheme:changed, modal:close) + // on render. Backbone.Events is the same thing the application installs. + if (!Common.NotificationCenter) { + Common.NotificationCenter = _.extend({}, Backbone.Events); + } }); \ No newline at end of file diff --git a/test/unit-tests/common/index.html b/test/unit-tests/common/index.html index 71de33810d..212fbb75ec 100644 --- a/test/unit-tests/common/index.html +++ b/test/unit-tests/common/index.html @@ -3,23 +3,29 @@ Unit Tests - +
- - + + + + - \ No newline at end of file + diff --git a/test/unit-tests/common/main/lib/component/Button.js b/test/unit-tests/common/main/lib/component/Button.js index 77afb01a05..67b9c9f86b 100644 --- a/test/unit-tests/common/main/lib/component/Button.js +++ b/test/unit-tests/common/main/lib/component/Button.js @@ -35,8 +35,8 @@ define([ 'backbone', - '../../../../../../../web-apps — копия/apps/common/main/lib/component/Button.js', - '../../../../../apps/common/main/lib/component/Menu.js' + 'common/main/lib/component/Button', + 'common/main/lib/component/Menu' ],function() { var chai = require('chai'), should = chai.should(); @@ -70,7 +70,7 @@ define([ button.caption.should.equal('update caption'); // dom - assert.equal(button.cmpEl.find('button:first').andSelf().filter('button').text(), 'update caption', 'dom caption'); + assert.equal(button.cmpEl.find('button:first').addBack().filter('button').text(), 'update caption', 'dom caption'); }); it('Button toggle', function(){ diff --git a/test/unit-tests/common/main/lib/util/utils.js b/test/unit-tests/common/main/lib/util/utils.js index a356c54550..78a103ac9b 100644 --- a/test/unit-tests/common/main/lib/util/utils.js +++ b/test/unit-tests/common/main/lib/util/utils.js @@ -34,7 +34,7 @@ */ define([ - '../../../../../../../web-apps — копия/apps/common/main/lib/util/utils.js' + 'common/main/lib/util/utils' ],function() { describe('Common.Utils.String', function(){ it('Test format', function(){