diff --git a/src/app/components/navbar/navbar.directive.js b/src/app/components/navbar/navbar.directive.js
index 48fc683..d046da1 100644
--- a/src/app/components/navbar/navbar.directive.js
+++ b/src/app/components/navbar/navbar.directive.js
@@ -10,9 +10,7 @@
var directive = {
restrict: 'E',
templateUrl: 'app/components/navbar/navbar.html',
- scope: {
- creationDate: '='
- },
+ scope: {},
controller: NavbarController,
controllerAs: 'vm',
bindToController: true
@@ -24,8 +22,6 @@
function NavbarController(moment, $modal, AuthService, Session, $scope, $state, AUTH_EVENTS) {
var vm = this;
- // "vm.creation" is avaible by directive option "bindToController: true"
- vm.relativeDate = moment(vm.creationDate).fromNow();
vm.currentUser = Session.getCurrentUser();
vm.modalInstance = null;
diff --git a/src/app/components/navbar/navbar.directive.spec.js b/src/app/components/navbar/navbar.directive.spec.js
index 5df48d1..3a2dffe 100644
--- a/src/app/components/navbar/navbar.directive.spec.js
+++ b/src/app/components/navbar/navbar.directive.spec.js
@@ -1,31 +1,19 @@
(function() {
'use strict';
- /**
- * @todo Complete the test
- * This example is not perfect.
- * Test should check if MomentJS have been called
- */
describe('directive navbar', function() {
- // var $window;
var vm;
var el;
- var timeInMs;
beforeEach(module('angular'));
- beforeEach(inject(function($compile, $rootScope) {
- // spyOn(_$window_, 'moment').and.callThrough();
- // $window = _$window_;
+ beforeEach(inject(function($compile, $rootScope, $httpBackend) {
+ $httpBackend.when('POST','/api/v1/login_from_cookie').respond({});
- timeInMs = new Date();
- timeInMs = timeInMs.setHours(timeInMs.getHours() - 24);
-
- el = angular.element('');
+ el = angular.element('');
$compile(el)($rootScope.$new());
$rootScope.$digest();
vm = el.isolateScope().vm;
- // ctrl = el.controller('acmeNavbar');
}));
it('should be compiled', function() {
@@ -34,17 +22,8 @@
it('should have isolate scope object with instanciate members', function() {
expect(vm).toEqual(jasmine.any(Object));
-
- expect(vm.creationDate).toEqual(jasmine.any(Number));
- expect(vm.creationDate).toEqual(timeInMs);
-
- expect(vm.relativeDate).toEqual(jasmine.any(String));
- expect(vm.relativeDate).toEqual('a day ago');
+ expect(vm.currentUser).toEqual(undefined);
});
- // it('should call Moment', function() {
- // console.log($window.moment)
- // expect($window.moment).toHaveBeenCalled();
- // });
});
})();
diff --git a/src/app/components/noosfero/profile-image/profile-image.directive.js b/src/app/components/noosfero/profile-image/profile-image.directive.js
index cc04133..2603ca6 100644
--- a/src/app/components/noosfero/profile-image/profile-image.directive.js
+++ b/src/app/components/noosfero/profile-image/profile-image.directive.js
@@ -24,7 +24,7 @@
function ProfileImageController() {
var vm = this;
vm.defaultIcon = 'fa-users';
- if(vm.profile.type==='Person') vm.defaultIcon = 'fa-user';
+ if(vm.profile && vm.profile.type==='Person') vm.defaultIcon = 'fa-user';
}
}
diff --git a/src/app/profile/profile.controller.spec.js b/src/app/profile/profile.controller.spec.js
index 587817d..a4f61f9 100644
--- a/src/app/profile/profile.controller.spec.js
+++ b/src/app/profile/profile.controller.spec.js
@@ -3,36 +3,10 @@
describe('controllers', function(){
var vm;
- var $timeout;
- var toastr;
beforeEach(module('angular'));
- beforeEach(inject(function(_$controller_, _$timeout_, _toastr_) {
- spyOn(_toastr_, 'info').and.callThrough();
-
+ beforeEach(inject(function(_$controller_) {
vm = _$controller_('MainController');
- $timeout = _$timeout_;
- toastr = _toastr_;
}));
-
- it('should have a timestamp creation date', function() {
- expect(vm.creationDate).toEqual(jasmine.any(Number));
- });
-
- it('should define animate class after delaying timeout ', function() {
- $timeout.flush();
- expect(vm.classAnimation).toEqual('rubberBand');
- });
-
- it('should show a Toastr info and stop animation when invoke showToastr()', function() {
- vm.showToastr();
- expect(toastr.info).toHaveBeenCalled();
- expect(vm.classAnimation).toEqual('');
- });
-
- it('should define more than 5 awesome things', function() {
- expect(angular.isArray(vm.awesomeThings)).toBeTruthy();
- expect(vm.awesomeThings.length === 5).toBeTruthy();
- });
});
})();
--
libgit2 0.21.2