Skip to content

Commit

Permalink
renamed modules
Browse files Browse the repository at this point in the history
grunt tests pass
app still doesn't work (rest service...)
  • Loading branch information
draptik committed Sep 3, 2013
1 parent 917ea4f commit 73db197
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 17 deletions.
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
.tmp
.sass-cache
app/bower_components
angularjs_frontend.sublime-project
20 changes: 16 additions & 4 deletions frontend/app/scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
'use strict';

angular.module('ngdemoApp', ['ngdemoApp.main', 'ngdemoApp.dummy', 'ngdemoApp.service'])
angular.module('ngdemoApp', [
'ngdemoApp.mainCtrl',
'ngdemoApp.dummyCtrl',
'ngdemoApp.factory'
])
.config(function ($routeProvider, $httpProvider) {
$routeProvider
.when('/dummy', {templateUrl: 'views/dummy.html', controller: 'DummyCtrl'})
.when('/', { templateUrl: 'views/main.html', controller: 'MainCtrl'})
.when('/dummy', {
templateUrl: 'views/dummy.html',
controller: 'DummyCtrl'
})
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/user', {
templateUrl: 'views/user-list.html',
controller: 'UserListCtrl'
})
.otherwise({ redirectTo: '/' });
.otherwise({
redirectTo: '/'
});

// http://stackoverflow.com/questions/17289195/angularjs-post-data-to-external-rest-api
$httpProvider.defaults.useXDomain = true;
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/scripts/controllers/dummy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

angular.module('ngdemoApp.dummy', ['ngdemoApp.service'])
angular.module('ngdemoApp.dummyCtrl', [])
.controller('DummyCtrl', function ($scope, dummyFactory) {
$scope.bla = 'bla from controller';
$scope.foo = dummyFactory.firstName;
Expand Down
16 changes: 8 additions & 8 deletions frontend/app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

angular.module('ngdemoApp.main', [])
.controller('MainCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
angular.module('ngdemoApp.mainCtrl', [])
.controller('MainCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
4 changes: 2 additions & 2 deletions frontend/app/scripts/services/dummyFactory.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var srv = angular.module('ngdemoApp.service', ['ngResource']);
var srv = angular.module('ngdemoApp.factory', ['ngResource']);

srv.factory('dummyFactory', function ($resource) {
return $resource('http://localhost\\:8080/ngdemo/web/dummy', {}, {
return $resource('http://localhost\\:8080/ngdemo/web/dummy', {}, {
query: { method: 'GET', params: {} }
});
});
27 changes: 27 additions & 0 deletions frontend/test/spec/controllers/dummy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

describe('Controller: DummyCtrl', function () {

// TODO! The tested module ('dummyCtrl') has a dependency on the module 'dummyFactory'.
// Since I don't know how to inject mocked dependencies using karma/jasmin
// yet, I'll bootstrap the complete application by loading the 'ngdemoApp' module...
beforeEach(module('ngdemoApp'));

// load the controller's module
beforeEach(module('ngdemoApp.dummyCtrl'));

var DummyCtrl,
scope;

// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
DummyCtrl = $controller('DummyCtrl', {
$scope: scope
});
}));

it('should attach a bla string to the scope', function () {
expect(scope.bla).toBe('bla from controller');
});
});
2 changes: 1 addition & 1 deletion frontend/test/spec/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe('Controller: MainCtrl', function () {

// load the controller's module
beforeEach(module('ngdemoApp.main'));
beforeEach(module('ngdemoApp.mainCtrl'));

var MainCtrl,
scope;
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/spec/services/dummyFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe('Service: dummyFactory', function () {

// load the service's module
beforeEach(module('ngdemoApp.service'));
beforeEach(module('ngdemoApp.factory'));

// instantiate service
var dummyFactory;
Expand Down

0 comments on commit 73db197

Please sign in to comment.