From 9c43659c1838ea886164a9814e020bcdc01549c1 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 21 Oct 2018 16:06:31 +0200 Subject: [PATCH] Tests fixed again. --- .../shared/services/comments.service.spec.ts | 19 +++++++++++++++++++ .../app/shared/services/comments.service.ts | 9 --------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Squidex/app/shared/services/comments.service.spec.ts b/src/Squidex/app/shared/services/comments.service.spec.ts index 13c5f2e3c..19d1f6b95 100644 --- a/src/Squidex/app/shared/services/comments.service.spec.ts +++ b/src/Squidex/app/shared/services/comments.service.spec.ts @@ -81,6 +81,25 @@ describe('CommentsService', () => { ); })); + it('should make get request to get comments and return empty result for 304', + inject([CommentsService, HttpTestingController], (commentsService: CommentsService, httpMock: HttpTestingController) => { + + let comments: CommentsDto; + + commentsService.getComments('my-app', 'my-comments', new Version('123')).subscribe(result => { + comments = result; + }); + + const req = httpMock.expectOne('http://service/p/api/apps/my-app/comments/my-comments'); + + expect(req.request.method).toEqual('GET'); + expect(req.request.headers.get('If-None-Match')).toBe('123'); + + req.flush({}, { status: 304, statusText: 'NotModified' }); + + expect(comments!).toEqual(new CommentsDto([], [], [], new Version('123'))); + })); + it('should make post request to create comment', inject([CommentsService, HttpTestingController], (commentsService: CommentsService, httpMock: HttpTestingController) => { diff --git a/src/Squidex/app/shared/services/comments.service.ts b/src/Squidex/app/shared/services/comments.service.ts index 18a694790..4a4f3a991 100644 --- a/src/Squidex/app/shared/services/comments.service.ts +++ b/src/Squidex/app/shared/services/comments.service.ts @@ -124,15 +124,6 @@ export class CommentsService { const url = this.apiUrl.buildUrl(`api/apps/${appName}/comments/${commentsId}/${commentId}`); return this.http.put(url, dto).pipe( - map(response => { - const body: any = response; - - return new CommentDto( - body.id, - DateTime.parseISO_UTC(body.time), - body.text, - body.user); - }), pretifyError('Failed to update comment.')); }