You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/04/09 19:28:22 UTC

git commit: AMBARI-5411. Karma integration. (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 81a0305df -> 8a79d247e


AMBARI-5411. Karma integration. (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8a79d247
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8a79d247
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8a79d247

Branch: refs/heads/trunk
Commit: 8a79d247efa83df9d0ea90c1a5652b5a9f592d42
Parents: 81a0305
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Apr 9 20:04:22 2014 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Apr 9 20:28:15 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/karma_setup.js |  25 ++++
 ambari-web/karma.conf.js                  | 158 +++++++++++++++++++++++++
 ambari-web/package.json                   |  16 ++-
 ambari-web/test/installer/step5_test.js   |   2 +-
 4 files changed, 196 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8a79d247/ambari-web/app/assets/test/karma_setup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/karma_setup.js b/ambari-web/app/assets/test/karma_setup.js
new file mode 100644
index 0000000..0560f50
--- /dev/null
+++ b/ambari-web/app/assets/test/karma_setup.js
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+document.write('<div id="mocha"></div>');
+document.write('<div id="wrapper"></div>');
+
+$.mocho = true;
+$.hostName = 'localhost:3333';
+mocha.ui('bdd');
+expect = chai.expect;

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a79d247/ambari-web/karma.conf.js
----------------------------------------------------------------------
diff --git a/ambari-web/karma.conf.js b/ambari-web/karma.conf.js
new file mode 100644
index 0000000..9d841dd
--- /dev/null
+++ b/ambari-web/karma.conf.js
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = function(config) {
+  config.set({
+
+    // base path, that will be used to resolve files and exclude
+    basePath: '',
+
+    plugins: [
+      'karma-mocha',
+      'karma-chai',
+      'karma-sinon',
+      'karma-phantomjs-launcher',
+      'karma-coverage',
+      'karma-ember-precompiler-brunch',
+      'karma-commonjs-require'
+    ],
+
+    // frameworks to use
+    frameworks: ['mocha', 'chai', 'sinon'],
+
+
+    // list of files / patterns to load in the browser
+    files: [
+
+//      'public/javascripts/vendor.js',
+//      'public/javascripts/app.js',
+//      'public/test/karma_setup.js',
+//      'public/test/javascripts/test.js',
+//      'public/test/tests.js'
+
+      'node_modules/karma-commonjs-require/node_modules/commonjs-require-definition/require.js',
+      'vendor/scripts/console-helper.js',
+      'vendor/scripts/jquery-1.7.2.min.js',
+      'vendor/scripts/handlebars-1.0.0.beta.6.js',
+      'vendor/scripts/ember-latest.js',
+      'vendor/scripts/ember-data-latest.js',
+      'vendor/scripts/ember-i18n-1.4.1.js',
+      'vendor/scripts/bootstrap.js',
+      'vendor/scripts/bootstrap-combobox.js',
+      'vendor/scripts/d3.v2.js',
+      'vendor/scripts/cubism.v1.js',
+      'vendor/scripts/jquery.ui.core.js',
+      'vendor/scripts/jquery.ui.widget.js',
+      'vendor/scripts/jquery.ui.mouse.js',
+      'vendor/scripts/jquery.ui.datepicker.js',
+      'vendor/scripts/jquery-ui-timepicker-addon.js',
+      'vendor/scripts/jquery.ui.slider.js',
+      'vendor/scripts/jquery.ui.sortable.js',
+      'vendor/scripts/jquery.ui.custom-effects.js',
+      'vendor/scripts/jquery.timeago.js',
+      'vendor/scripts/jquery.ajax-retry.js',
+      'vendor/scripts/workflow_visualization.js',
+      'vendor/scripts/rickshaw.js',
+      'vendor/scripts/spin.js',
+      'vendor/scripts/jquery.flexibleArea.js',
+      'vendor/scripts/FileSaver.js',
+      'vendor/scripts/Blob.js',
+      'vendor/**/*.js',
+      'app/templates/**/*.hbs',
+      'app!(assets)/**/!(karma_setup|tests).js',
+      'app/assets/test/karma_setup.js',
+      {
+        pattern: 'app/assets/data/**',
+        served: true,
+        included: false,
+        watched: true
+      },
+      'test/**/*.js',
+      'app/assets/test/tests.js'
+    ],
+
+    emberPrecompilerBrunchPreprocessor: {
+      jqueryPath: 'vendor/scripts/jquery-1.7.2.min.js',
+      emberPath: 'vendor/scripts/ember-latest.js',
+      handlebarsPath: 'vendor/scripts/handlebars-1.0.0.beta.6.js'
+    },
+
+    commonRequirePreprocessor: {
+      appDir: 'app'
+    },
+
+    coverageReporter: {
+      type: 'html',
+      dir: 'public/coverage/'
+    },
+
+    preprocessors: {
+//      '!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage',
+      'app/templates/**/*.hbs': ['ember-precompiler-brunch', 'common-require'],
+      'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
+      'test/**/*.js': ['common-require']
+    },
+
+    // list of files to exclude
+    exclude: [
+
+    ],
+
+
+    // test results reporter to use
+    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
+//    reporters: ['progress', 'coverage'],
+    reporters: ['progress'],
+
+
+    // web server port
+    port: 9876,
+
+
+    // enable / disable colors in the output (reporters and logs)
+    colors: true,
+
+
+    // level of logging
+    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+    logLevel: config.LOG_INFO,
+
+
+    // enable / disable watching file and executing tests whenever any file changes
+    autoWatch: true,
+
+
+    // Start these browsers, currently available:
+    // - Chrome
+    // - ChromeCanary
+    // - Firefox
+    // - Opera (has to be installed with `npm install karma-opera-launcher`)
+    // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
+    // - PhantomJS
+    // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
+    browsers: ['PhantomJS'],
+
+    // If browser does not capture in given timeout [ms], kill it
+    captureTimeout: 60000,
+
+
+    // Continuous Integration mode
+    // if true, it capture browsers, run tests and exit
+    singleRun: false
+  });
+};

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a79d247/ambari-web/package.json
----------------------------------------------------------------------
diff --git a/ambari-web/package.json b/ambari-web/package.json
index 572e1cb..3d10f7c 100644
--- a/ambari-web/package.json
+++ b/ambari-web/package.json
@@ -24,9 +24,17 @@
   },
   "devDependencies":{
     "mocha":"1.9.0",
-    "chai":"*",
-    "sinon":"*",
-    "sinon-chai":"*",
-    "express":"2.5.8"
+    "chai":"~1.9.0",
+    "sinon":"=1.7.3",
+    "sinon-chai":"~2.5.0",
+    "express":"2.5.8",
+    "karma": "=0.11.14",
+    "karma-mocha": "~0.1.1",
+    "karma-chai": "~0.1.0",
+    "karma-sinon": "~1.0.2",
+    "karma-phantomjs-launcher": "~0.1.3",
+    "karma-coverage": "~0.2.0",
+    "karma-commonjs-require": "~0.0.1",
+    "karma-ember-precompiler-brunch": "~0.0.1"
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a79d247/ambari-web/test/installer/step5_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/installer/step5_test.js b/ambari-web/test/installer/step5_test.js
index a672900..c759820 100644
--- a/ambari-web/test/installer/step5_test.js
+++ b/ambari-web/test/installer/step5_test.js
@@ -148,7 +148,7 @@ describe('App.WizardStep5Controller', function () {
 
     it('should be host name different from localhost if hosts number more than one', function() {
       var hosts = [
-        {host_name: ''},
+        {host_name: location.hostname},
         {host_name: 'host2'}
       ];
       //first host_name is empty string, because of location.hostname = "" in console,