diff --git a/app/app.js b/app/app.js index 21eccdb8ea..e15171ed46 100644 --- a/app/app.js +++ b/app/app.js @@ -1,12 +1,24 @@ -'use strict'; - -// Declare app level module which depends on views, and components -angular.module('myApp', [ - 'ngRoute', - 'myApp.view1', - 'myApp.view2', - 'myApp.version' -]). -config(['$routeProvider', function($routeProvider) { - $routeProvider.otherwise({redirectTo: '/view1'}); -}]); +(function() { + + 'use strict'; + + // Declare app level module which depends on views, and components + angular + .module('myApp', [ + 'ngRoute', + 'myApp.view1', + 'myApp.view2', + 'myApp.version' + ]) + .config(Config); + + Config.$inject = ['$routeProvider']; + + function Config($routeProvider) { + $routeProvider + .otherwise({ + redirectTo: '/view1' + }); + } + +})(); diff --git a/app/components/version/interpolate-filter.js b/app/components/version/interpolate-filter.js index 03bb1987df..f261a2ba3f 100644 --- a/app/components/version/interpolate-filter.js +++ b/app/components/version/interpolate-filter.js @@ -1,9 +1,17 @@ -'use strict'; +(function() { -angular.module('myApp.version.interpolate-filter', []) + 'use strict'; -.filter('interpolate', ['version', function(version) { - return function(text) { - return String(text).replace(/\%VERSION\%/mg, version); - }; -}]); + angular + .module('myApp.version.interpolate-filter', []) + .filter('interpolate', Interpolate); + + Interpolate.$inject = ['version']; + + function Interpolate(version) { + return function(text) { + return String(text).replace(/\%VERSION\%/mg, version); + }; + } + +})(); diff --git a/app/components/version/interpolate-filter_test.js b/app/components/version/interpolate-filter_test.js index ff56c529eb..f7554e95ae 100644 --- a/app/components/version/interpolate-filter_test.js +++ b/app/components/version/interpolate-filter_test.js @@ -1,9 +1,9 @@ 'use strict'; -describe('myApp.version module', function() { +describe('module: myApp.version', function() { beforeEach(module('myApp.version')); - describe('interpolate filter', function() { + describe('filter: interpolate', function() { beforeEach(module(function($provide) { $provide.value('version', 'TEST_VER'); })); diff --git a/app/components/version/version-directive.js b/app/components/version/version-directive.js index 74088f8add..9fa59f9bc6 100644 --- a/app/components/version/version-directive.js +++ b/app/components/version/version-directive.js @@ -1,9 +1,19 @@ -'use strict'; +(function() { + 'use strict'; -angular.module('myApp.version.version-directive', []) + angular + .module('myApp.version.version-directive', []) + .directive('appVersion', AppVersion); -.directive('appVersion', ['version', function(version) { - return function(scope, elm, attrs) { - elm.text(version); - }; -}]); + AppVersion.$inject = ['version']; + + function AppVersion(version) { + return { + link: link + }; + + function link(scope, element, attrs) { + element.text(version); + } + } +})(); diff --git a/app/components/version/version.js b/app/components/version/version.js index cb7a10f9db..b378a65344 100644 --- a/app/components/version/version.js +++ b/app/components/version/version.js @@ -1,8 +1,11 @@ -'use strict'; +(function() { + 'use strict'; -angular.module('myApp.version', [ - 'myApp.version.interpolate-filter', - 'myApp.version.version-directive' -]) + angular + .module('myApp.version', [ + 'myApp.version.interpolate-filter', + 'myApp.version.version-directive' + ]) + .value('version', '0.1'); -.value('version', '0.1'); +})(); diff --git a/app/view1/view1.js b/app/view1/view1.js index 4ce0b4f118..77930c4a41 100644 --- a/app/view1/view1.js +++ b/app/view1/view1.js @@ -1,14 +1,25 @@ -'use strict'; +(function() { -angular.module('myApp.view1', ['ngRoute']) + 'use strict'; -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/view1', { - templateUrl: 'view1/view1.html', - controller: 'View1Ctrl' - }); -}]) + angular + .module('myApp.view1', [ + 'ngRoute' + ]) + .config(Config) + .controller('View1Ctrl', View1Ctrl); -.controller('View1Ctrl', [function() { + Config.$inject = ['$routeProvider']; -}]); \ No newline at end of file + function Config($routeProvider) { + $routeProvider.when('/view1', { + templateUrl: 'view1/view1.html', + controller: 'View1Ctrl' + }); + } + + function View1Ctrl() { + + } + +})(); diff --git a/app/view1/view1_test.js b/app/view1/view1_test.js index 14ba79b48f..67f6ec6e5b 100644 --- a/app/view1/view1_test.js +++ b/app/view1/view1_test.js @@ -1,16 +1,17 @@ 'use strict'; -describe('myApp.view1 module', function() { - +describe('module: myApp.view1', function() { beforeEach(module('myApp.view1')); - describe('view1 controller', function(){ + describe('controller: View1Ctrl', function() { + var ctrl; - it('should ....', inject(function($controller) { - //spec body - var view1Ctrl = $controller('View1Ctrl'); - expect(view1Ctrl).toBeDefined(); + beforeEach(inject(function($controller) { + ctrl = $controller('View1Ctrl'); })); + it('should be defined', function() { + expect(ctrl).toBeDefined(); + }); }); }); \ No newline at end of file diff --git a/app/view2/view2.js b/app/view2/view2.js index a0ff97dbd7..3b1270bd7f 100644 --- a/app/view2/view2.js +++ b/app/view2/view2.js @@ -1,14 +1,26 @@ -'use strict'; -angular.module('myApp.view2', ['ngRoute']) +(function() { + "use strict"; -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/view2', { - templateUrl: 'view2/view2.html', - controller: 'View2Ctrl' - }); -}]) + angular + .module('myApp.view2', [ + 'ngRoute' + ]) + .config(Config) + .controller('View2Ctrl', View2Ctrl); -.controller('View2Ctrl', [function() { + Config.$inject = ['$routeProvider']; -}]); \ No newline at end of file + function Config($routeProvider) { + $routeProvider + .when('/view2', { + templateUrl: 'view2/view2.html', + controller: 'View2Ctrl' + }); + } + + function View2Ctrl() { + + } + +})(); \ No newline at end of file diff --git a/app/view2/view2_test.js b/app/view2/view2_test.js index 07b34d6bb3..3e2e92c133 100644 --- a/app/view2/view2_test.js +++ b/app/view2/view2_test.js @@ -1,16 +1,17 @@ 'use strict'; -describe('myApp.view2 module', function() { +describe('module: myApp.view2', function() { + beforeEach(module('myApp.view2')); - beforeEach(module('myApp.view2')); + describe('controller: View2Ctrl', function() { + var ctrl; - describe('view2 controller', function(){ + beforeEach(inject(function($controller) { + ctrl = $controller('View2Ctrl'); + })); - it('should ....', inject(function($controller) { - //spec body - var view2Ctrl = $controller('View2Ctrl'); - expect(view2Ctrl).toBeDefined(); - })); - - }); + it('should be defined', function() { + expect(ctrl).toBeDefined(); + }); + }); }); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 44bb29f1ab..f1d9ec155e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,33 +1,34 @@ -module.exports = function(config){ - config.set({ +module.exports = function (config) { + config.set({ - basePath : './', + basePath: './', - files : [ - 'app/bower_components/angular/angular.js', - 'app/bower_components/angular-route/angular-route.js', - 'app/bower_components/angular-mocks/angular-mocks.js', - 'app/components/**/*.js', - 'app/view*/**/*.js' - ], + files: [ + 'app/bower_components/angular/angular.js', + 'app/bower_components/angular-route/angular-route.js', + 'app/bower_components/angular-mocks/angular-mocks.js', + 'app/components/**/*.js', + 'app/view*/**/*.js' + ], - autoWatch : true, + autoWatch: true, - frameworks: ['jasmine'], + frameworks: ['jasmine'], - browsers : ['Chrome'], + browsers: ['PhantomJS'], - plugins : [ - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-jasmine', - 'karma-junit-reporter' - ], + plugins: [ + 'karma-phantomjs-launcher', + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-jasmine', + 'karma-junit-reporter' + ], - junitReporter : { - outputFile: 'test_out/unit.xml', - suite: 'unit' - } + junitReporter: { + outputFile: 'test_out/unit.xml', + suite: 'unit' + } - }); + }); }; diff --git a/package.json b/package.json index d0edbc8b61..6343e41ef8 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "license": "MIT", "devDependencies": { "bower": "^1.3.1", + "cz-conventional-changelog": "^1.1.4", "http-server": "^0.6.1", "jasmine-core": "^2.3.4", "karma": "~0.12", @@ -14,25 +15,26 @@ "karma-firefox-launcher": "^0.1.6", "karma-jasmine": "^0.3.5", "karma-junit-reporter": "^0.2.2", + "karma-phantomjs-launcher": "^0.2.1", "protractor": "^2.1.0", "shelljs": "^0.2.6" }, "scripts": { "postinstall": "bower install", - "prestart": "npm install", "start": "http-server -a localhost -p 8000 -c-1", - "pretest": "npm install", "test": "karma start karma.conf.js", "test-single-run": "karma start karma.conf.js --single-run", - "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", - "preprotractor": "npm run update-webdriver", "protractor": "protractor e2e-tests/protractor.conf.js", - "update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + sed(/sourceMappingURL=angular-loader.min.js.map/,'sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map','app/bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\"" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } } }