From 1708fd67e719aa01cd8d1e639342c143851845d4 Mon Sep 17 00:00:00 2001 From: Oussama Elgoumri Date: Fri, 30 Oct 2015 11:57:40 +0000 Subject: [PATCH 1/3] chore(package.json): add PhantomJS, and commitizen --- package.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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" + } } } From b44b04c329ceadb10447008b014abe26c7885401 Mon Sep 17 00:00:00 2001 From: Oussama Elgoumri Date: Fri, 30 Oct 2015 14:10:28 +0000 Subject: [PATCH 2/3] style(javascript): follow jhon papa style guide --- app/app.js | 36 +++++++++----- app/components/version/interpolate-filter.js | 24 ++++++--- .../version/interpolate-filter_test.js | 4 +- app/components/version/version-directive.js | 26 +++++++--- app/components/version/version.js | 15 +++--- app/view1/view1.js | 32 ++++++++---- app/view1/view1_test.js | 21 ++++---- app/view2/view2.js | 32 ++++++++---- app/view2/view2_test.js | 21 ++++---- karma.conf.js | 49 ++++++++++--------- 10 files changed, 162 insertions(+), 98 deletions(-) diff --git a/app/app.js b/app/app.js index 21eccdb8ea..1f4460ec3e 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..21ee21976f 100644 --- a/app/components/version/interpolate-filter.js +++ b/app/components/version/interpolate-filter.js @@ -1,9 +1,19 @@ -'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..5135ccbc04 100644 --- a/app/components/version/version-directive.js +++ b/app/components/version/version-directive.js @@ -1,9 +1,21 @@ -'use strict'; +(function() { + 'use strict'; -angular.module('myApp.version.version-directive', []) + angular + .module('myApp.version.version-directive', [ -.directive('appVersion', ['version', function(version) { - return function(scope, elm, attrs) { - elm.text(version); - }; -}]); + ]) + .directive('appVersion', AppVersion); + + 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..430428338e 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..f9c107f9d1 100644 --- a/app/view1/view1.js +++ b/app/view1/view1.js @@ -1,14 +1,26 @@ -'use strict'; -angular.module('myApp.view1', ['ngRoute']) +(function() { -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/view1', { - templateUrl: 'view1/view1.html', - controller: 'View1Ctrl' - }); -}]) + 'use strict'; -.controller('View1Ctrl', [function() { + angular + .module('myApp.view1', [ + 'ngRoute' + ]) + .config(Config) + .controller('View1Ctrl', View1Ctrl); -}]); \ No newline at end of file + Config.$inject = ['$routeProvider']; + + 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..ec728dbbba 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')); - beforeEach(module('myApp.view1')); + describe('controller: View1Ctrl', function() { + var ctrl; - describe('view1 controller', function(){ + beforeEach(inject(function($controller) { + ctrl = $controller('View1Ctrl'); + })); - it('should ....', inject(function($controller) { - //spec body - var view1Ctrl = $controller('View1Ctrl'); - expect(view1Ctrl).toBeDefined(); - })); - - }); + 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' + } - }); + }); }; From c770e7d9d3bc8b853ee5389d0b63e2a083926fa4 Mon Sep 17 00:00:00 2001 From: Oussama Elgoumri Date: Fri, 30 Oct 2015 14:31:44 +0000 Subject: [PATCH 3/3] style(javascript): tabs to spaces --- app/app.js | 36 ++++++++++---------- app/components/version/interpolate-filter.js | 18 +++++----- app/components/version/version-directive.js | 4 +-- app/components/version/version.js | 6 ++-- app/view1/view1.js | 33 +++++++++--------- app/view1/view1_test.js | 20 +++++------ 6 files changed, 56 insertions(+), 61 deletions(-) diff --git a/app/app.js b/app/app.js index 1f4460ec3e..e15171ed46 100644 --- a/app/app.js +++ b/app/app.js @@ -1,24 +1,24 @@ -(function () { +(function() { - 'use strict'; + 'use strict'; - // Declare app level module which depends on views, and components - angular - .module('myApp', [ - 'ngRoute', - 'myApp.view1', - 'myApp.view2', - 'myApp.version' - ]) - .config(Config); + // 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']; + Config.$inject = ['$routeProvider']; - function Config($routeProvider) { - $routeProvider - .otherwise({ - redirectTo: '/view1' - }); - } + function Config($routeProvider) { + $routeProvider + .otherwise({ + redirectTo: '/view1' + }); + } })(); diff --git a/app/components/version/interpolate-filter.js b/app/components/version/interpolate-filter.js index 21ee21976f..f261a2ba3f 100644 --- a/app/components/version/interpolate-filter.js +++ b/app/components/version/interpolate-filter.js @@ -3,17 +3,15 @@ 'use strict'; angular - .module('myApp.version.interpolate-filter', [ + .module('myApp.version.interpolate-filter', []) + .filter('interpolate', Interpolate); - ]) - .filter('interpolate', Interpolate); + Interpolate.$inject = ['version']; - Interpolate.$inject = ['version']; - - function Interpolate(version) { - return function(text) { - return String(text).replace(/\%VERSION\%/mg, version); - }; - } + function Interpolate(version) { + return function(text) { + return String(text).replace(/\%VERSION\%/mg, version); + }; + } })(); diff --git a/app/components/version/version-directive.js b/app/components/version/version-directive.js index 5135ccbc04..9fa59f9bc6 100644 --- a/app/components/version/version-directive.js +++ b/app/components/version/version-directive.js @@ -2,9 +2,7 @@ 'use strict'; angular - .module('myApp.version.version-directive', [ - - ]) + .module('myApp.version.version-directive', []) .directive('appVersion', AppVersion); AppVersion.$inject = ['version']; diff --git a/app/components/version/version.js b/app/components/version/version.js index 430428338e..b378a65344 100644 --- a/app/components/version/version.js +++ b/app/components/version/version.js @@ -3,9 +3,9 @@ angular .module('myApp.version', [ - 'myApp.version.interpolate-filter', - 'myApp.version.version-directive' - ]) + 'myApp.version.interpolate-filter', + 'myApp.version.version-directive' + ]) .value('version', '0.1'); })(); diff --git a/app/view1/view1.js b/app/view1/view1.js index f9c107f9d1..77930c4a41 100644 --- a/app/view1/view1.js +++ b/app/view1/view1.js @@ -1,26 +1,25 @@ - (function() { - 'use strict'; + 'use strict'; - angular - .module('myApp.view1', [ - 'ngRoute' - ]) - .config(Config) - .controller('View1Ctrl', View1Ctrl); + angular + .module('myApp.view1', [ + 'ngRoute' + ]) + .config(Config) + .controller('View1Ctrl', View1Ctrl); - Config.$inject = ['$routeProvider']; + Config.$inject = ['$routeProvider']; - function Config($routeProvider) { - $routeProvider.when('/view1', { - templateUrl: 'view1/view1.html', - controller: 'View1Ctrl' - }); - } + function Config($routeProvider) { + $routeProvider.when('/view1', { + templateUrl: 'view1/view1.html', + controller: 'View1Ctrl' + }); + } - function View1Ctrl() { + function View1Ctrl() { - } + } })(); diff --git a/app/view1/view1_test.js b/app/view1/view1_test.js index ec728dbbba..67f6ec6e5b 100644 --- a/app/view1/view1_test.js +++ b/app/view1/view1_test.js @@ -1,17 +1,17 @@ 'use strict'; describe('module: myApp.view1', function() { - beforeEach(module('myApp.view1')); + beforeEach(module('myApp.view1')); - describe('controller: View1Ctrl', function() { - var ctrl; + describe('controller: View1Ctrl', function() { + var ctrl; - beforeEach(inject(function($controller) { - ctrl = $controller('View1Ctrl'); - })); + beforeEach(inject(function($controller) { + ctrl = $controller('View1Ctrl'); + })); - it('should be defined', function() { - expect(ctrl).toBeDefined(); - }); - }); + it('should be defined', function() { + expect(ctrl).toBeDefined(); + }); + }); }); \ No newline at end of file