Skip to content

Commit

Permalink
refact(*): refactor app layout to conform to best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Broadstone authored and petebacondarwin committed Aug 20, 2014
1 parent 0edde11 commit 9d0b43b
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 83 deletions.
File renamed without changes.
12 changes: 12 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'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'});
}]);
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

/* Directives */


angular.module('myApp.directives', []).
angular.module('myApp.version').
directive('appVersion', ['version', function(version) {
return function(scope, elm, attrs) {
elm.text(version);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

/* jasmine specs for directives go here */

describe('directives', function() {
beforeEach(module('myApp.directives'));
describe('version directives', function() {
beforeEach(module('myApp.version'));

describe('app-version', function() {
it('should print current version', function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

/* Filters */

angular.module('myApp.filters', []).
angular.module('myApp.version').
filter('interpolate', ['version', function(version) {
return function(text) {
return String(text).replace(/\%VERSION\%/mg, version);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
'use strict';

/* jasmine specs for filters go here */

describe('filter', function() {
beforeEach(module('myApp.filters'));

describe('version filter', function() {
beforeEach(module('myApp.version'));

describe('interpolate', function() {
beforeEach(module(function($provide) {
$provide.value('version', 'TEST_VER');
}));


it('should replace VERSION', inject(function(interpolateFilter) {
expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after');
}));
Expand Down
4 changes: 4 additions & 0 deletions app/components/version/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

angular.module('myApp.version', []).
value('version', '0.1');
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

/* jasmine specs for services go here */

describe('service', function() {
beforeEach(module('myApp.services'));

describe('version service', function() {
beforeEach(module('myApp.version'));

describe('version', function() {
it('should return current version', inject(function(version) {
Expand Down
Empty file removed app/css/.gitkeep
Empty file.
Empty file removed app/img/.gitkeep
Empty file.
11 changes: 6 additions & 5 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/version-filter.js"></script>
</body>
</html>
16 changes: 0 additions & 16 deletions app/js/app.js

This file was deleted.

11 changes: 0 additions & 11 deletions app/js/controllers.js

This file was deleted.

9 changes: 0 additions & 9 deletions app/js/services.js

This file was deleted.

Empty file removed app/partials/.gitkeep
Empty file.
File renamed without changes.
12 changes: 12 additions & 0 deletions app/view1/view1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

angular.module('myApp.view1', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl'
});
}])
.controller('View1Ctrl', [function() {

}]);
12 changes: 12 additions & 0 deletions app/view1/view1_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

describe('view1 controller', function(){
beforeEach(module('myApp.view1'));

it('should ....', inject(function($controller) {
//spec body
var view1Ctrl = $controller('View1Ctrl');
expect(view1Ctrl).toBeDefined();
}));

});
File renamed without changes.
12 changes: 12 additions & 0 deletions app/view2/view2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

angular.module('myApp.view2', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view2', {
templateUrl: 'view2/view2.html',
controller: 'View2Ctrl'
});
}])
.controller('View2Ctrl', [function() {

}]);
11 changes: 11 additions & 0 deletions app/view2/view2_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

describe('controllers', function(){
beforeEach(module('myApp.view2'));

it('should ....', inject(function($controller) {
//spec body
var view2Ctrl = $controller('View2Ctrl');
expect(view2Ctrl).toBeDefined();
}));
});
1 change: 1 addition & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = function(config){
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/js/**/*.js',
'app/components/version/version.js',
'test/unit/**/*.js'
],

Expand Down
20 changes: 0 additions & 20 deletions test/unit/controllersSpec.js

This file was deleted.

0 comments on commit 9d0b43b

Please sign in to comment.