Browse Source

Tests fixed again.

pull/329/head
Sebastian Stehle 7 years ago
parent
commit
9c43659c18
  1. 19
      src/Squidex/app/shared/services/comments.service.spec.ts
  2. 9
      src/Squidex/app/shared/services/comments.service.ts

19
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) => {

9
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.'));
}

Loading…
Cancel
Save