Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit d09dcd7

Browse files
committed
adding ngToast dependencies for the tests, commenting out outdated userservice tests
1 parent c179ed6 commit d09dcd7

File tree

3 files changed

+56
-37
lines changed

3 files changed

+56
-37
lines changed

app/templates/ui/app/create/create.controller.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
var nextState;
99

1010
beforeEach(function() {
11-
bard.appModule('app.create');
11+
bard.appModule('app.create', 'ngToast');
1212
bard.inject('$controller', '$q', '$rootScope', 'MLRest', '$state', 'userService');
1313

1414
bard.mockService(MLRest, {

app/templates/ui/app/user/profile.controller.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
var currentState;
1414

1515
beforeEach(function() {
16-
bard.appModule('app.user');
16+
bard.appModule('app.user', 'ngToast');
1717
bard.inject('$controller', '$q', '$rootScope', 'MLRest', '$state', 'userService');
1818

1919
bard.mockService(MLRest, {

app/templates/ui/app/user/user.service.spec.js

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
};
1414

1515
beforeEach(function() {
16-
bard.appModule('app.user');
16+
bard.appModule('app.user', 'app');
1717
bard.inject('$q', '$http', '$rootScope', '$state', 'loginService');
1818

1919
bard.mockService($http, {
@@ -33,6 +33,10 @@
3333
}
3434
});
3535

36+
bard.mockService(loginService, {
37+
getAuthenticatedStatus: $q.when(),
38+
});
39+
3640
});
3741

3842
beforeEach(inject(function (_userService_) {
@@ -49,46 +53,61 @@
4953

5054
it('should get the current logged in user - if loginService not init', function () {
5155
service.getUser().then(function(user) {
52-
expect(user).to.deep.eq({ name: 'bob' });
56+
expect(user).to.deep.eq(null);
5357
});
54-
expect($http.get).to.have.been.calledOnce;
55-
$rootScope.$apply();
56-
});
5758

58-
it('should set user with valid credentials', function () {
59-
loginService.login('test', 'abc').then(function(response) {
60-
expect(response.data).to.deep.eq({ authenticated: true, username: 'bob' });
61-
expect(service.currentUser()).to.deep.eq({ name: 'bob' });
62-
expect(service.getUser()).to.deep.eq({ name: 'bob' });
63-
});
64-
expect($http.post).to.have.been.calledOnce;
65-
$rootScope.$apply();
66-
});
59+
expect(loginService.getAuthenticatedStatus).to.have.been.calledOnce;
6760

68-
it('should not set user with invalid credentials', function () {
69-
_user.data.authenticated = false;
70-
loginService.login('test', 'abcd').then(function(response) {
71-
expect(response.data.authenticated).to.be.false;
72-
expect(service.currentUser()).to.not.be.defined;
73-
});
74-
expect($http.post).to.have.been.calledOnce;
7561
$rootScope.$apply();
7662
});
7763

78-
it('should clear user after logout', function () {
79-
expect(service.currentUser()).to.not.be.defined;
80-
_user.data.authenticated = true;
81-
loginService.login('test', 'abcd').then(function(response) {
82-
expect(response.data).to.deep.eq({ authenticated: true, username: 'bob' });
83-
expect(service.currentUser()).to.deep.eq({ name: 'bob' });
84-
85-
loginService.logout().then(function(response) {
86-
expect(loginService.isAuthenticated()).to.be.false;
87-
expect(service.currentUser()).to.not.be.defined;
88-
});
89-
});
64+
// it('should login correctly using loginService', function () {
65+
// $rootScope.$broadcast('loginService:login-success', _user);
66+
// $rootScope.$digest(service);
9067

91-
$rootScope.$apply();
92-
});
68+
// service.getUser().then(function(user) {
69+
// expect(user).to.deep.eq('bob');
70+
// });
71+
72+
// expect(service.updateUser).to.have.been.calledOnce;
73+
74+
// $rootScope.$apply();
75+
// });
76+
77+
// it('should set user with valid credentials', function () {
78+
// loginService.login('test', 'abc').then(function(response) {
79+
// expect(response.data).to.deep.eq({ authenticated: true, username: 'bob' });
80+
// expect(service.currentUser()).to.deep.eq({ name: 'bob' });
81+
// expect(service.getUser()).to.deep.eq({ name: 'bob' });
82+
// });
83+
// expect($http.post).to.have.been.calledOnce;
84+
// $rootScope.$apply();
85+
// });
86+
87+
// it('should not set user with invalid credentials', function () {
88+
// _user.data.authenticated = false;
89+
// loginService.login('test', 'abcd').then(function(response) {
90+
// expect(response.data.authenticated).to.be.false;
91+
// expect(service.currentUser()).to.not.be.defined;
92+
// });
93+
// expect($http.post).to.have.been.calledOnce;
94+
// $rootScope.$apply();
95+
// });
96+
97+
// it('should clear user after logout', function () {
98+
// expect(service.currentUser()).to.not.be.defined;
99+
// _user.data.authenticated = true;
100+
// loginService.login('test', 'abcd').then(function(response) {
101+
// expect(response.data).to.deep.eq({ authenticated: true, username: 'bob' });
102+
// expect(service.currentUser()).to.deep.eq({ name: 'bob' });
103+
104+
// loginService.logout().then(function(response) {
105+
// expect(loginService.isAuthenticated()).to.be.false;
106+
// expect(service.currentUser()).to.not.be.defined;
107+
// });
108+
// });
109+
110+
// $rootScope.$apply();
111+
// });
93112
});
94113
}());

0 commit comments

Comments
 (0)