Skip to content

Commit 8d2ebbc

Browse files
author
welcome-dev
committed
Update path in tests
Updated tests to account for new "/" prefix in the path.
1 parent 278273c commit 8d2ebbc

12 files changed

+49
-49
lines changed

modules/articles/client/config/articles-admin.client.routes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
template: '<ui-view/>'
1616
})
1717
.state('admin.articles.list', {
18-
url: '',
19-
templateUrl: 'modules/articles/client/views/admin/list-articles.client.view.html',
18+
url: '/',
19+
templateUrl: '/modules/articles/client/views/admin/list-articles.client.view.html',
2020
controller: 'ArticlesAdminListController',
2121
controllerAs: 'vm',
2222
data: {
@@ -25,7 +25,7 @@
2525
})
2626
.state('admin.articles.create', {
2727
url: '/create',
28-
templateUrl: 'modules/articles/client/views/admin/form-article.client.view.html',
28+
templateUrl: '/modules/articles/client/views/admin/form-article.client.view.html',
2929
controller: 'ArticlesAdminController',
3030
controllerAs: 'vm',
3131
data: {
@@ -37,7 +37,7 @@
3737
})
3838
.state('admin.articles.edit', {
3939
url: '/:articleId/edit',
40-
templateUrl: 'modules/articles/client/views/admin/form-article.client.view.html',
40+
templateUrl: '/modules/articles/client/views/admin/form-article.client.view.html',
4141
controller: 'ArticlesAdminController',
4242
controllerAs: 'vm',
4343
data: {

modules/articles/tests/client/admin.articles.client.controller.tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
it('should send a POST request with the form input values and then locate to new object URL', inject(function (ArticlesService) {
8989
// Set POST response
90-
$httpBackend.expectPOST('api/articles', sampleArticlePostData).respond(mockArticle);
90+
$httpBackend.expectPOST('/api/articles', sampleArticlePostData).respond(mockArticle);
9191

9292
// Run controller functionality
9393
$scope.vm.save(true);
@@ -101,7 +101,7 @@
101101

102102
it('should call Notification.error if error', function () {
103103
var errorMessage = 'this is an error message';
104-
$httpBackend.expectPOST('api/articles', sampleArticlePostData).respond(400, {
104+
$httpBackend.expectPOST('/api/articles', sampleArticlePostData).respond(400, {
105105
message: errorMessage
106106
});
107107

modules/articles/tests/client/admin.articles.client.routes.tests.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
});
5454

5555
it('Should have templateUrl', function () {
56-
expect(liststate.templateUrl).toBe('modules/articles/client/views/admin/list-articles.client.view.html');
56+
expect(liststate.templateUrl).toBe('/modules/articles/client/views/admin/list-articles.client.view.html');
5757
});
5858
});
5959

@@ -64,7 +64,7 @@
6464

6565
beforeEach(inject(function ($controller, $state, $templateCache) {
6666
createstate = $state.get('admin.articles.create');
67-
$templateCache.put('modules/articles/client/views/admin/form-article.client.view.html', '');
67+
$templateCache.put('/modules/articles/client/views/admin/form-article.client.view.html', '');
6868

6969
// Create mock article
7070
mockArticle = new ArticlesService();
@@ -99,7 +99,7 @@
9999
});
100100

101101
it('Should have templateUrl', function () {
102-
expect(createstate.templateUrl).toBe('modules/articles/client/views/admin/form-article.client.view.html');
102+
expect(createstate.templateUrl).toBe('/modules/articles/client/views/admin/form-article.client.view.html');
103103
});
104104
});
105105

@@ -110,7 +110,7 @@
110110

111111
beforeEach(inject(function ($controller, $state, $templateCache) {
112112
editstate = $state.get('admin.articles.edit');
113-
$templateCache.put('modules/articles/client/views/admin/form-article.client.view.html', '');
113+
$templateCache.put('/modules/articles/client/views/admin/form-article.client.view.html', '');
114114

115115
// Create mock article
116116
mockArticle = new ArticlesService({
@@ -150,7 +150,7 @@
150150
});
151151

152152
it('Should have templateUrl', function () {
153-
expect(editstate.templateUrl).toBe('modules/articles/client/views/admin/form-article.client.view.html');
153+
expect(editstate.templateUrl).toBe('/modules/articles/client/views/admin/form-article.client.view.html');
154154
});
155155

156156
xit('Should go to unauthorized route', function () {

modules/articles/tests/client/admin.list.articles.client.controller.tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
it('should send a GET request and return all articles', inject(function (ArticlesService) {
7878
// Set POST response
79-
$httpBackend.expectGET('api/articles').respond(mockArticleList);
79+
$httpBackend.expectGET('/api/articles').respond(mockArticleList);
8080

8181

8282
$httpBackend.flush();

modules/articles/tests/client/articles.client.routes.tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
});
5454

5555
it('Should have templateUrl', function () {
56-
expect(liststate.templateUrl).toBe('modules/articles/client/views/list-articles.client.view.html');
56+
expect(liststate.templateUrl).toBe('/modules/articles/client/views/list-articles.client.view.html');
5757
});
5858
});
5959

modules/chat/tests/client/chat.client.routes.tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
});
3535

3636
it('Should have templateUrl', function () {
37-
expect(mainstate.templateUrl).toBe('modules/chat/client/views/chat.client.view.html');
37+
expect(mainstate.templateUrl).toBe('/modules/chat/client/views/chat.client.view.html');
3838
});
3939
});
4040

@@ -54,7 +54,7 @@
5454
$rootScope.$digest();
5555

5656
expect($location.path()).toBe('/chat');
57-
expect($state.current.templateUrl).toBe('modules/chat/client/views/chat.client.view.html');
57+
expect($state.current.templateUrl).toBe('/modules/chat/client/views/chat.client.view.html');
5858
}));
5959
});
6060

modules/users/client/services/users.client.service.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@
1515
},
1616
updatePassword: {
1717
method: 'POST',
18-
url: 'api/users/password'
18+
url: '/api/users/password'
1919
},
2020
deleteProvider: {
2121
method: 'DELETE',
22-
url: 'api/users/accounts',
22+
url: '/api/users/accounts',
2323
params: {
2424
provider: '@provider'
2525
}
2626
},
2727
sendPasswordResetToken: {
2828
method: 'POST',
29-
url: 'api/auth/forgot'
29+
url: '/api/auth/forgot'
3030
},
3131
resetPasswordWithToken: {
3232
method: 'POST',
33-
url: 'api/auth/reset/:token'
33+
url: '/api/auth/reset/:token'
3434
},
3535
signup: {
3636
method: 'POST',
37-
url: 'api/auth/signup'
37+
url: '/api/auth/signup'
3838
},
3939
signin: {
4040
method: 'POST',
41-
url: 'api/auth/signin'
41+
url: '/api/auth/signin'
4242
}
4343
});
4444

modules/users/client/views/settings/change-profile-picture.client.view.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</div>
1010
</div>
1111
<div class="form-group text-center">
12-
<img ng-src="{{vm.fileSelected ? croppedDataUrl : vm.user.profileImageURL}}" alt="{{vm.user.displayName}}" class="img-thumbnail user-profile-picture" ngf-drop>
12+
<img ng-src="{{vm.fileSelected ? croppedDataUrl : '/' + vm.user.profileImageURL}}" alt="{{vm.user.displayName}}" class="img-thumbnail user-profile-picture" ngf-drop>
1313
</div>
1414
<div ng-show="!vm.fileSelected" class="text-center form-group">
1515
<button class="btn btn-default btn-file" ngf-select="vm.fileSelected = true" ng-model="picFile" accept="image/*">Select Picture</button>

modules/users/tests/client/authentication.client.controller.tests.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
describe('$scope.signin()', function () {
5757
it('should login with a correct username and password', function () {
5858
// Test expected GET request
59-
$httpBackend.when('POST', 'api/auth/signin').respond(200, { username: 'Fred' });
59+
$httpBackend.when('POST', '/api/auth/signin').respond(200, { username: 'Fred' });
6060

6161
scope.vm.signin(true);
6262
$httpBackend.flush();
@@ -93,7 +93,7 @@
9393
spyOn($state, 'go');
9494

9595
// Test expected GET request
96-
$httpBackend.when('POST', 'api/auth/signin').respond(200, 'Fred');
96+
$httpBackend.when('POST', '/api/auth/signin').respond(200, 'Fred');
9797

9898
scope.vm.signin(true);
9999
$httpBackend.flush();
@@ -106,7 +106,7 @@
106106

107107
it('should fail to log in with nothing', function () {
108108
// Test expected POST request
109-
$httpBackend.expectPOST('api/auth/signin').respond(400, {
109+
$httpBackend.expectPOST('/api/auth/signin').respond(400, {
110110
'message': 'Missing credentials'
111111
});
112112

@@ -123,7 +123,7 @@
123123
scope.vm.credentials = 'Bar';
124124

125125
// Test expected POST request
126-
$httpBackend.expectPOST('api/auth/signin').respond(400, {
126+
$httpBackend.expectPOST('/api/auth/signin').respond(400, {
127127
'message': 'Unknown user'
128128
});
129129

@@ -139,7 +139,7 @@
139139
it('should register with correct data', function () {
140140
// Test expected GET request
141141
scope.vm.authentication.user = 'Fred';
142-
$httpBackend.when('POST', 'api/auth/signup').respond(200, { username: 'Fred' });
142+
$httpBackend.when('POST', '/api/auth/signup').respond(200, { username: 'Fred' });
143143

144144
scope.vm.signup(true);
145145
$httpBackend.flush();
@@ -152,7 +152,7 @@
152152

153153
it('should fail to register with duplicate Username', function () {
154154
// Test expected POST request
155-
$httpBackend.when('POST', 'api/auth/signup').respond(400, {
155+
$httpBackend.when('POST', '/api/auth/signup').respond(400, {
156156
'message': 'Username already exists'
157157
});
158158

modules/users/tests/client/password.client.controller.tests.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
describe('POST error', function() {
9797
var errorMessage = 'No account with that username has been found';
9898
beforeEach(function() {
99-
$httpBackend.when('POST', 'api/auth/forgot', credentials).respond(400, {
99+
$httpBackend.when('POST', '/api/auth/forgot', credentials).respond(400, {
100100
'message': errorMessage
101101
});
102102

@@ -116,7 +116,7 @@
116116
describe('POST success', function() {
117117
var successMessage = 'An email has been sent to the provided email with further instructions.';
118118
beforeEach(function() {
119-
$httpBackend.when('POST', 'api/auth/forgot', credentials).respond({
119+
$httpBackend.when('POST', '/api/auth/forgot', credentials).respond({
120120
'message': successMessage
121121
});
122122

@@ -146,7 +146,7 @@
146146

147147
it('POST error should call Notification.error with response message', function() {
148148
var errorMessage = 'Passwords do not match';
149-
$httpBackend.when('POST', 'api/auth/reset/' + token, passwordDetails).respond(400, {
149+
$httpBackend.when('POST', '/api/auth/reset/' + token, passwordDetails).respond(400, {
150150
'message': errorMessage
151151
});
152152

@@ -161,7 +161,7 @@
161161
username: 'test'
162162
};
163163
beforeEach(function() {
164-
$httpBackend.when('POST', 'api/auth/reset/' + token, passwordDetails).respond(user);
164+
$httpBackend.when('POST', '/api/auth/reset/' + token, passwordDetails).respond(user);
165165

166166
scope.vm.resetUserPassword(true);
167167
$httpBackend.flush();

modules/users/tests/client/users-admin.client.routes.tests.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
});
3535

3636
it('Should have templateUrl', function () {
37-
expect(mainstate.templateUrl).toBe('modules/users/client/views/admin/list-users.client.view.html');
37+
expect(mainstate.templateUrl).toBe('/modules/users/client/views/admin/list-users.client.view.html');
3838
});
3939
});
4040

@@ -53,7 +53,7 @@
5353
});
5454

5555
it('Should have templateUrl', function () {
56-
expect(viewstate.templateUrl).toBe('modules/users/client/views/admin/view-user.client.view.html');
56+
expect(viewstate.templateUrl).toBe('/modules/users/client/views/admin/view-user.client.view.html');
5757
});
5858
});
5959

@@ -72,7 +72,7 @@
7272
});
7373

7474
it('Should have templateUrl', function () {
75-
expect(editstate.templateUrl).toBe('modules/users/client/views/admin/edit-user.client.view.html');
75+
expect(editstate.templateUrl).toBe('/modules/users/client/views/admin/edit-user.client.view.html');
7676
});
7777
});
7878

@@ -92,7 +92,7 @@
9292
$rootScope.$digest();
9393

9494
expect($location.path()).toBe('/admin/users');
95-
expect($state.current.templateUrl).toBe('modules/users/client/views/admin/list-users.client.view.html');
95+
expect($state.current.templateUrl).toBe('/modules/users/client/views/admin/list-users.client.view.html');
9696
}));
9797
});
9898

0 commit comments

Comments
 (0)