mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-7688] Reduce the usage of LogService and TranslateModule (tests) (#9567)
This commit is contained in:
@@ -20,28 +20,18 @@ import { CommentModel } from '../../models/comment.model';
|
||||
import { CommentListComponent } from './comment-list.component';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import {
|
||||
commentUserNoPictureDefined,
|
||||
commentUserPictureDefined,
|
||||
mockCommentOne,
|
||||
testUser
|
||||
} from './mocks/comment-list.mock';
|
||||
import { commentUserNoPictureDefined, commentUserPictureDefined, mockCommentOne, testUser } from './mocks/comment-list.mock';
|
||||
import { CommentListServiceMock } from './mocks/comment-list.service.mock';
|
||||
import { ADF_COMMENTS_SERVICE } from '../interfaces/comments.token';
|
||||
|
||||
describe('CommentListComponent', () => {
|
||||
|
||||
let commentList: CommentListComponent;
|
||||
let fixture: ComponentFixture<CommentListComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
],
|
||||
imports: [CoreTestingModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_COMMENTS_SERVICE,
|
||||
@@ -123,7 +113,7 @@ describe('CommentListComponent', () => {
|
||||
|
||||
it('comment date time should start with Yesterday when comment date is yesterday', async () => {
|
||||
const commentOld = new CommentModel(mockCommentOne);
|
||||
commentOld.created = new Date((Date.now() - 24 * 3600 * 1000));
|
||||
commentOld.created = new Date(Date.now() - 24 * 3600 * 1000);
|
||||
commentList.comments = [commentOld];
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -135,7 +125,7 @@ describe('CommentListComponent', () => {
|
||||
|
||||
it('comment date time should not start with Today/Yesterday when comment date is before yesterday', async () => {
|
||||
const commentOld = new CommentModel(mockCommentOne);
|
||||
commentOld.created = new Date((Date.now() - 24 * 3600 * 1000 * 2));
|
||||
commentOld.created = new Date(Date.now() - 24 * 3600 * 1000 * 2);
|
||||
commentList.comments = [commentOld];
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@@ -19,7 +19,6 @@ import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommentsComponent } from './comments.component';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CommentsServiceMock, commentsResponseMock } from './mocks/comments.service.mock';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { ADF_COMMENTS_SERVICE } from './interfaces/comments.token';
|
||||
@@ -34,10 +33,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
],
|
||||
imports: [CoreTestingModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_COMMENTS_SERVICE,
|
||||
@@ -60,7 +56,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
it('should load comments when id specified', () => {
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({id: change});
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
expect(getCommentSpy).toHaveBeenCalled();
|
||||
});
|
||||
@@ -70,7 +66,7 @@ describe('CommentsComponent', () => {
|
||||
getCommentSpy.and.returnValue(throwError({}));
|
||||
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({id: change});
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
});
|
||||
@@ -82,7 +78,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
it('should display comments when the entity has comments', async () => {
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({id: change});
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -93,7 +89,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
it('should display comments count when the entity has comments', async () => {
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({id: change});
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -114,7 +110,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
it('should display comments input by default', async () => {
|
||||
const change = new SimpleChange(null, '123', true);
|
||||
component.ngOnChanges({id: change});
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -141,7 +137,7 @@ describe('CommentsComponent', () => {
|
||||
});
|
||||
|
||||
it('should fetch new comments when id changed', () => {
|
||||
component.ngOnChanges({id: change});
|
||||
component.ngOnChanges({ id: change });
|
||||
expect(getCommentSpy).toHaveBeenCalledWith('456');
|
||||
});
|
||||
|
||||
@@ -151,13 +147,12 @@ describe('CommentsComponent', () => {
|
||||
});
|
||||
|
||||
it('should not fetch new comments when id changed to null', () => {
|
||||
component.ngOnChanges({id: nullChange});
|
||||
component.ngOnChanges({ id: nullChange });
|
||||
expect(getCommentSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Add comment', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.id = '123';
|
||||
fixture.detectChanges();
|
||||
@@ -229,7 +224,7 @@ describe('CommentsComponent', () => {
|
||||
});
|
||||
|
||||
it('should clear comment when escape key is pressed', async () => {
|
||||
const event = new KeyboardEvent('keydown', {key: 'Escape'});
|
||||
const event = new KeyboardEvent('keydown', { key: 'Escape' });
|
||||
let element = fixture.nativeElement.querySelector('#comment-input');
|
||||
element.dispatchEvent(event);
|
||||
|
||||
@@ -271,5 +266,5 @@ describe('CommentsComponent', () => {
|
||||
component.addComment();
|
||||
expect(addCommentSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user