diff --git a/client/src/app/posts/post-list/post-list.component.spec.ts b/client/src/app/posts/post-list/post-list.component.spec.ts index 54358338894c8f3565181308f12a84a36c015505..c2c37bcda49cda542cacdf9ee48190337df8d098 100644 --- a/client/src/app/posts/post-list/post-list.component.spec.ts +++ b/client/src/app/posts/post-list/post-list.component.spec.ts @@ -32,7 +32,8 @@ describe('PostListComponent', () => { owner: "user", imageUrl: null, price: 49, - categoryid: 1 + categoryid: 1, + status: 0, }), new Post({ id: 2, @@ -42,7 +43,8 @@ describe('PostListComponent', () => { owner: "user", imageUrl: null, price: 159, - categoryid: 2 + categoryid: 2, + status: 0, }) ]); }) @@ -58,7 +60,8 @@ describe('PostListComponent', () => { owner: "user", imageUrl: null, price: 49, - categoryid: 1 + categoryid: 1, + status: 0, }) ]); }) diff --git a/client/src/app/posts/post.service.spec.ts b/client/src/app/posts/post.service.spec.ts index 8892d17f4a09c1fce8d9bb0e5cffdc54f6d07d28..8250c5879bc0f1aa77f9fb42fcbba56e2d45a0d0 100644 --- a/client/src/app/posts/post.service.spec.ts +++ b/client/src/app/posts/post.service.spec.ts @@ -265,7 +265,7 @@ describe('PostService', () => { describe('getPostsByCategory', () => { it('should get posts by category', () => { // Gets posts by category and checks values - service.getPostsByCategory(2, 0, 0, 100).then(posts => { + service.getPostsByCategory(2, undefined, 0, 0, 100).then(posts => { for (let i = 0; i < posts.length; i++) { expect(posts[i].getId).toBe(i + 1); expect(posts[i].getTitle).toBe("Test" + (i + 1)); @@ -276,7 +276,7 @@ describe('PostService', () => { }); // Mocks and checks HTTP request - const req = httpMock.expectOne("api/post/?categoryid=2&sort=0&min_price=0&max_price=100"); + const req = httpMock.expectOne("api/post/?categoryid=2&location=undefined&sort=0&min_price=0&max_price=100"); expect(req.request.method).toBe("GET"); req.flush({ data: [{ @@ -303,12 +303,12 @@ describe('PostService', () => { it('should reject on invalid post', () => { // Gets invalid post, should go to catch - service.getPostsByCategory(52, 0, 0, 100).then(posts => { + service.getPostsByCategory(52, undefined, 0, 0, 100).then(posts => { fail(); }).catch(error => {}); // Mocks and checks HTTP request - const req = httpMock.expectOne("api/post/?categoryid=52&sort=0&min_price=0&max_price=100"); + const req = httpMock.expectOne("api/post/?categoryid=52&location=undefined&sort=0&min_price=0&max_price=100"); expect(req.request.method).toBe("GET"); req.flush({ data: [{ @@ -322,12 +322,12 @@ describe('PostService', () => { it('should reject on http error', () => { // Gets HTTP error instead of post, should catch - service.getPostsByCategory(35, 0, 0, 100).then(post => { + service.getPostsByCategory(35, undefined, 0, 0, 100).then(post => { fail(); }).catch(error => {}); // Mocks and checks HTTP request - const req = httpMock.expectOne("api/post/?categoryid=35&sort=0&min_price=0&max_price=100"); + const req = httpMock.expectOne("api/post/?categoryid=35&location=undefined&sort=0&min_price=0&max_price=100"); expect(req.request.method).toBe("GET"); req.error(new ErrorEvent("400")); }); diff --git a/client/src/app/users/user-guest-profile/user-guest-profile.component.spec.ts b/client/src/app/users/user-guest-profile/user-guest-profile.component.spec.ts index 789c4505e223114b46e74e052b9816c12f238b92..22bd787416ce784c6ca2a76d175e727b0b019100 100644 --- a/client/src/app/users/user-guest-profile/user-guest-profile.component.spec.ts +++ b/client/src/app/users/user-guest-profile/user-guest-profile.component.spec.ts @@ -4,6 +4,7 @@ import { ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { Review } from 'src/app/models/review.model'; import { User } from 'src/app/models/user.model'; +import { UserLoginFormComponent } from '../user-login-form/user-login-form.component'; import { UserService } from '../user.service'; import { UserGuestProfileComponent } from './user-guest-profile.component'; @@ -42,7 +43,13 @@ describe('UserGuestProfileComponent', () => { await TestBed.configureTestingModule({ declarations: [ UserGuestProfileComponent ], - imports: [ HttpClientTestingModule, RouterTestingModule ], + imports: [ + HttpClientTestingModule, + RouterTestingModule.withRoutes([ + { path: 'user', component: UserGuestProfileComponent}, + { path: 'login', component: UserLoginFormComponent}, + ]) + ], providers: [ { provide: ActivatedRoute, useValue: { snapshot: {params: {id: 1}}}}, { provide: UserService, useValue: mockUserService }