← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21090: Add ngHtml2Js processor for karma unit tests

 

------------------------------------------------------------
revno: 21090
committer: Mark Polak <markpo@xxxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-17 16:09:34 +0100
message:
  Add ngHtml2Js processor for karma unit tests
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/package.json
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/karma.config.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/package.json'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/package.json	2015-11-10 20:39:56 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/package.json	2015-11-17 15:09:34 +0000
@@ -17,32 +17,33 @@
   "license": "BSD-3-Clause",
   "dependencies": {},
   "devDependencies": {
+    "angular-mocks": "1.3.15",
     "babel-core": "6.1.2",
+    "babel-eslint": "4.1.5",
     "babel-loader": "6.1.0",
+    "babel-preset-es2015": "6.1.2",
     "chai": "3.4.1",
+    "eslint": "1.9.0",
+    "eslint-config-dhis2": "0.0.5",
+    "eslint-plugin-react": "3.8.0",
     "karma": "0.13.15",
     "karma-chai": "0.1.0",
     "karma-chrome-launcher": "0.2.1",
     "karma-cli": "0.1.1",
+    "karma-coverage": "0.5.3",
     "karma-mocha": "0.2.0",
+    "karma-ng-html2js-preprocessor": "^0.2.0",
+    "karma-phantomjs-launcher": "0.2.1",
+    "karma-sinon": "1.0.4",
+    "karma-sinon-chai": "1.1.0",
     "karma-sourcemap-loader": "0.3.6",
     "karma-webpack": "1.7.0",
     "mocha": "2.3.3",
-    "webpack": "1.12.3",
-    "angular-mocks": "1.3.15",
-    "babel-eslint": "4.1.5",
-    "babel-preset-es2015": "6.1.2",
-    "eslint": "1.9.0",
-    "eslint-config-dhis2": "0.0.5",
-    "eslint-plugin-react": "3.8.0",
-    "karma-coverage": "0.5.3",
-    "karma-phantomjs-launcher": "0.2.1",
-    "karma-sinon": "1.0.4",
-    "karma-sinon-chai": "1.1.0",
     "phantomjs": "1.9.18",
     "phantomjs-polyfill": "0.0.1",
     "sinon": "1.17.2",
-    "sinon-chai": "2.8.0"
+    "sinon-chai": "2.8.0",
+    "webpack": "1.12.3"
   },
   "keywords": [
     "Tracker",

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/karma.config.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/karma.config.js	2015-11-10 20:20:50 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/karma.config.js	2015-11-17 15:09:34 +0000
@@ -1,3 +1,5 @@
+var path = require('path');
+
 module.exports = function karmaConfigHandler(config) {
     config.set({
         browsers: [ 'PhantomJS' ], // run in Headless browser PhantomJS
@@ -18,6 +20,7 @@
         preprocessors: {
             'tests.webpack.js': [ 'webpack', 'sourcemap' ], // preprocess with webpack and our sourcemap loader
             '../dhis2.angular.*.js': ['coverage'],
+            // '../views/left-bar.html': ['ng-html2js'], // Example for transforming html files to be angular modules that are cached
         },
         reporters: [ 'dots', 'coverage' ], // report results in this format
         coverageReporter: {
@@ -36,6 +39,17 @@
                 ],
             },
         },
+
+        ngHtml2JsPreprocessor: {
+            cacheIdFromPath: function(filepath) {
+                return filepath.replace(path.normalize(__dirname + '/..') + '/', '');
+            },
+
+            moduleName: function (htmlPath, originalPath) {
+                return htmlPath;
+            }
+        },
+
         webpackServer: {
             noInfo: true, // please don't spam the console when running in karma!
         },