mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
ACS-8652: Noop Translation Module for better unit testing ergonomics (#10118)
This commit is contained in:
@@ -18,9 +18,8 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AboutServerSettingsComponent } from './about-server-settings.component';
|
||||
import { AppConfigService } from '../../app-config/app-config.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { AppConfigServiceMock } from '../../common';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
const aboutGithubDetails = {
|
||||
url: 'https://github.com/componany/repository/commits/',
|
||||
@@ -38,7 +37,7 @@ describe('AboutServerSettingsComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||
});
|
||||
fixture = TestBed.createComponent(AboutServerSettingsComponent);
|
||||
|
@@ -21,12 +21,11 @@ import { AuthGuardBpm } from './auth-guard-bpm.service';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
import { RouterStateSnapshot, Router } from '@angular/router';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('AuthGuardService BPM', () => {
|
||||
let authGuard: AuthGuardBpm;
|
||||
@@ -39,7 +38,7 @@ describe('AuthGuardService BPM', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, MatDialogModule],
|
||||
imports: [NoopTranslateModule, MatDialogModule],
|
||||
providers: [
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
|
||||
{
|
||||
|
@@ -21,13 +21,12 @@ import { AuthGuardEcm } from './auth-guard-ecm.service';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
import { RouterStateSnapshot, Router } from '@angular/router';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('AuthGuardService ECM', () => {
|
||||
let authGuard: AuthGuardEcm;
|
||||
@@ -39,7 +38,7 @@ describe('AuthGuardService ECM', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, RouterTestingModule, MatDialogModule],
|
||||
imports: [NoopTranslateModule, RouterTestingModule, MatDialogModule],
|
||||
providers: [
|
||||
BasicAlfrescoAuthService,
|
||||
AppConfigService,
|
||||
|
@@ -20,8 +20,7 @@ import { ActivatedRouteSnapshot, Router } from '@angular/router';
|
||||
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
|
||||
import { JwtHelperService } from '../services/jwt-helper.service';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('Auth Guard SSO role service', () => {
|
||||
let authGuard: AuthGuardSsoRoleService;
|
||||
@@ -30,7 +29,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, MatDialogModule]
|
||||
imports: [NoopTranslateModule, MatDialogModule]
|
||||
});
|
||||
localStorage.clear();
|
||||
authGuard = TestBed.inject(AuthGuardSsoRoleService);
|
||||
|
@@ -20,15 +20,14 @@ import { Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { AppConfigService } from '../../app-config/app-config.service';
|
||||
import { AuthGuard } from './auth-guard.service';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
|
||||
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('AuthGuardService', () => {
|
||||
let state;
|
||||
@@ -42,7 +41,7 @@ describe('AuthGuardService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, MatDialogModule, RouterTestingModule],
|
||||
imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule],
|
||||
providers: [
|
||||
AppConfigService,
|
||||
StorageService,
|
||||
|
@@ -19,7 +19,6 @@ import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { CookieService } from '../../common/services/cookie.service';
|
||||
import { AppConfigService } from '../../app-config/app-config.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
|
||||
import { AuthModule } from '../oidc/auth.module';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
@@ -30,6 +29,7 @@ import { OAuthEvent } from 'angular-oauth2-oidc';
|
||||
import { Subject } from 'rxjs';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { Injector } from '@angular/core';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
declare let jasmine: any;
|
||||
// eslint-disable-next-line
|
||||
@@ -42,7 +42,7 @@ xdescribe('AuthenticationService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), AuthModule.forRoot({ useHash: true }), HttpClientModule],
|
||||
imports: [NoopTranslateModule, AuthModule.forRoot({ useHash: true }), HttpClientModule],
|
||||
providers: [
|
||||
{
|
||||
provide: CookieService,
|
||||
|
@@ -27,9 +27,8 @@ import {
|
||||
mockIdentityGroups,
|
||||
roleMappingMock
|
||||
} from '../mock/identity-group.mock';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AdfHttpClient } from '../../../../api/src';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('IdentityGroupService', () => {
|
||||
let service: IdentityGroupService;
|
||||
@@ -38,7 +37,7 @@ describe('IdentityGroupService', () => {
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [AdfHttpClient]
|
||||
});
|
||||
service = TestBed.inject(IdentityGroupService);
|
||||
|
@@ -32,10 +32,9 @@ import { IdentityUserService } from './identity-user.service';
|
||||
import { JwtHelperService } from './jwt-helper.service';
|
||||
import { mockToken } from '../mock/jwt-helper.service.spec';
|
||||
import { IdentityRoleModel } from '../models/identity-role.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AdfHttpClient } from '../../../../api/src';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('IdentityUserService', () => {
|
||||
const mockRoles = [
|
||||
@@ -53,7 +52,7 @@ describe('IdentityUserService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [StorageService, AdfHttpClient]
|
||||
});
|
||||
storageService = TestBed.inject(StorageService);
|
||||
|
@@ -21,7 +21,7 @@ import { MatCheckbox, MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { CardViewBoolItemComponent } from './card-view-boolitem.component';
|
||||
import { CardViewBoolItemModel } from '../../models/card-view-boolitem.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('CardViewBoolItemComponent', () => {
|
||||
let fixture: ComponentFixture<CardViewBoolItemComponent>;
|
||||
@@ -29,7 +29,7 @@ describe('CardViewBoolItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()]
|
||||
imports: [NoopTranslateModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewBoolItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SelectFilterInputComponent } from './select-filter-input.component';
|
||||
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('SelectFilterInputComponent', () => {
|
||||
let fixture: ComponentFixture<SelectFilterInputComponent>;
|
||||
@@ -28,7 +28,7 @@ describe('SelectFilterInputComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, TranslateModule.forRoot(), MatSelectModule],
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, MatSelectModule],
|
||||
providers: [MatSelect]
|
||||
});
|
||||
|
||||
|
@@ -19,12 +19,8 @@ import { Component, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, tick, fakeAsync } from '@angular/core/testing';
|
||||
import { ClipboardService } from './clipboard.service';
|
||||
import { ClipboardDirective } from './clipboard.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { TranslationService } from '../translation';
|
||||
import { TranslationMock } from '../mock';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-test-component',
|
||||
@@ -42,8 +38,7 @@ describe('ClipboardDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, MatSnackBarModule, MatButtonModule, ClipboardDirective],
|
||||
providers: [ClipboardService, { provide: TranslationService, useClass: TranslationMock }],
|
||||
imports: [NoopTranslateModule, MatSnackBarModule, ClipboardDirective],
|
||||
declarations: [TestTargetClipboardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestTargetClipboardComponent);
|
||||
@@ -86,8 +81,7 @@ describe('CopyClipboardDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, MatSnackBarModule, ClipboardDirective],
|
||||
providers: [ClipboardService, { provide: TranslationService, useClass: TranslationMock }],
|
||||
imports: [NoopTranslateModule, MatSnackBarModule, ClipboardDirective],
|
||||
declarations: [TestCopyClipboardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestCopyClipboardComponent);
|
||||
|
@@ -19,20 +19,16 @@ import { NotificationService } from '../notifications/services/notification.serv
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ClipboardService } from './clipboard.service';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { TranslationService } from '../translation';
|
||||
import { TranslationMock } from '../mock';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('ClipboardService', () => {
|
||||
let clipboardService: ClipboardService;
|
||||
let notificationService: NotificationService;
|
||||
let inputElement;
|
||||
let inputElement: HTMLInputElement;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule, MatSnackBarModule],
|
||||
providers: [ClipboardService, { provide: TranslationService, useClass: TranslationMock }]
|
||||
imports: [NoopTranslateModule, MatSnackBarModule]
|
||||
});
|
||||
clipboardService = TestBed.inject(ClipboardService);
|
||||
notificationService = TestBed.inject(NotificationService);
|
||||
|
@@ -19,11 +19,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommentModel } from '../../models/comment.model';
|
||||
import { CommentListComponent } from './comment-list.component';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
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';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('CommentListComponent', () => {
|
||||
let commentList: CommentListComponent;
|
||||
@@ -32,7 +31,7 @@ describe('CommentListComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_COMMENTS_SERVICE,
|
||||
|
@@ -18,13 +18,12 @@
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommentsComponent } from './comments.component';
|
||||
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';
|
||||
import { CommentsService } from './interfaces/comments-service.interface';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('CommentsComponent', () => {
|
||||
let component: CommentsComponent;
|
||||
@@ -35,7 +34,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, HttpClientTestingModule, TranslateModule.forRoot(), CommentsComponent],
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, CommentsComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_COMMENTS_SERVICE,
|
||||
|
@@ -17,18 +17,17 @@
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { DirectionalityConfigService } from './directionality-config.service';
|
||||
import { directionalityConfigFactory } from './directionality-config-factory';
|
||||
import { APP_INITIALIZER } from '@angular/core';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('DirectionalityConfigService', () => {
|
||||
let userPreferencesService: UserPreferencesService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [
|
||||
UserPreferencesService,
|
||||
{
|
||||
|
@@ -16,15 +16,14 @@
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { AppConfigService } from '../../app-config/app-config.service';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { UserPreferencesService, UserPreferenceValues } from '../../common/services/user-preferences.service';
|
||||
import { AppConfigServiceMock } from '../mock/app-config.service.mock';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { AlfrescoApiServiceMock, TranslationMock } from '../../mock';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { TranslationService } from '../../translation';
|
||||
import { AlfrescoApiServiceMock } from '../../mock';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('UserPreferencesService', () => {
|
||||
const supportedPaginationSize = [5, 10, 15, 20];
|
||||
@@ -36,11 +35,8 @@ describe('UserPreferencesService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), HttpClientTestingModule],
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [
|
||||
UserPreferencesService,
|
||||
StorageService,
|
||||
{ provide: TranslationService, useClass: TranslationMock },
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||
]
|
||||
|
@@ -20,11 +20,10 @@ import { DateCellComponent } from './date-cell.component';
|
||||
import { DataColumn, DateConfig } from '../../data/data-column.model';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { AppConfigService } from '../../../app-config';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { LOCALE_ID } from '@angular/core';
|
||||
import { registerLocaleData } from '@angular/common';
|
||||
import localePL from '@angular/common/locales/pl';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
let component: DateCellComponent;
|
||||
let appConfigService: AppConfigService;
|
||||
@@ -62,11 +61,7 @@ const checkDisplayedTooltip = (expectedTooltip: string) => {
|
||||
|
||||
const configureTestingModule = (providers: any[]) => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
DateCellComponent,
|
||||
HttpClientTestingModule,
|
||||
TranslateModule.forRoot()
|
||||
],
|
||||
imports: [DateCellComponent, NoopTranslateModule],
|
||||
providers
|
||||
});
|
||||
fixture = TestBed.createComponent(DateCellComponent);
|
||||
|
@@ -20,7 +20,7 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/materia
|
||||
import { ConfirmDialogComponent } from './confirm.dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('Confirm Dialog Component', () => {
|
||||
let fixture: ComponentFixture<ConfirmDialogComponent>;
|
||||
@@ -39,7 +39,7 @@ describe('Confirm Dialog Component', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatDialogModule, NoopAnimationsModule, TranslateModule.forRoot()],
|
||||
imports: [MatDialogModule, NoopAnimationsModule, NoopTranslateModule],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: data }
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { JsonPipe, NgClass, NgForOf, NgIf, NgStyle, NgTemplateOutlet, UpperCasePipe } from '@angular/common';
|
||||
import { Component, Inject, Injector, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Inject, Injector, Input, OnDestroy, OnInit, Optional, ViewEncapsulation } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -77,8 +77,9 @@ export class FormRendererComponent<T> implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
public formService: FormService,
|
||||
private formRulesManager: FormRulesManager<T>,
|
||||
@Optional()
|
||||
@Inject(FORM_FIELD_MODEL_RENDER_MIDDLEWARE)
|
||||
private middlewareServices: FormFieldModelRenderMiddleware[]
|
||||
private middlewareServices?: FormFieldModelRenderMiddleware[]
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -161,14 +162,16 @@ export class FormRendererComponent<T> implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private runMiddlewareServices(): void {
|
||||
const formFields = this.formDefinition.getFormFields();
|
||||
if (this.middlewareServices && this.middlewareServices.length > 0) {
|
||||
const formFields = this.formDefinition.getFormFields();
|
||||
|
||||
formFields.forEach((field) => {
|
||||
this.middlewareServices.forEach((middlewareService) => {
|
||||
if (middlewareService.type === field.type) {
|
||||
field = middlewareService.getParsedField(field);
|
||||
}
|
||||
formFields.forEach((field) => {
|
||||
this.middlewareServices.forEach((middlewareService) => {
|
||||
if (middlewareService.type === field.type) {
|
||||
field = middlewareService.getParsedField(field);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,13 +20,13 @@ import { FormFieldModel } from '../core/form-field.model';
|
||||
import { AmountWidgetComponent, ADF_AMOUNT_SETTINGS } from './amount.widget';
|
||||
import { FormBaseModule } from '../../../form-base.module';
|
||||
import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { FormModel } from '../core/form.model';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatInputHarness } from '@angular/material/input/testing';
|
||||
import { MatFormFieldHarness } from '@angular/material/form-field/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('AmountWidgetComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
@@ -36,7 +36,7 @@ describe('AmountWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormBaseModule]
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, FormBaseModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(AmountWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -135,7 +135,7 @@ describe('AmountWidgetComponent - rendering', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormBaseModule]
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, FormBaseModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(AmountWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -331,7 +331,7 @@ describe('AmountWidgetComponent settings', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormBaseModule],
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, FormBaseModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_AMOUNT_SETTINGS,
|
||||
|
@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormFieldModel } from '../core/form-field.model';
|
||||
import { FormModel } from '../core/form.model';
|
||||
import { DateTimeWidgetComponent } from './date-time.widget';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
@@ -29,7 +28,7 @@ import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatDatetimepickerModule, MatNativeDatetimeModule } from '@mat-datetimepicker/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('DateTimeWidgetComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
@@ -41,8 +40,7 @@ describe('DateTimeWidgetComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
HttpClientTestingModule,
|
||||
NoopTranslateModule,
|
||||
NoopAnimationsModule,
|
||||
MatDialogModule,
|
||||
MatNativeDatetimeModule,
|
||||
|
@@ -23,10 +23,8 @@ import { FormModel } from '../core/form.model';
|
||||
import { FormFieldModel } from '../core/form-field.model';
|
||||
import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { MultilineTextWidgetComponentComponent } from './multiline-text.widget';
|
||||
import { ComponentFixture, getTestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { TranslationService } from '../../../../translation/translation.service';
|
||||
import { TranslationMock } from '../../../../mock/translation.service.mock';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('MultilineTextWidgetComponentComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
@@ -35,11 +33,10 @@ describe('MultilineTextWidgetComponentComponent', () => {
|
||||
let element: HTMLElement;
|
||||
|
||||
beforeEach(() => {
|
||||
getTestBed().configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule],
|
||||
providers: [{ provide: TranslationService, useClass: TranslationMock }]
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, MultilineTextWidgetComponentComponent]
|
||||
});
|
||||
fixture = getTestBed().createComponent(MultilineTextWidgetComponentComponent);
|
||||
fixture = TestBed.createComponent(MultilineTextWidgetComponentComponent);
|
||||
widget = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||
|
@@ -20,11 +20,11 @@ import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { FormFieldModel } from '../core/form-field.model';
|
||||
import { FormModel } from '../core/form.model';
|
||||
import { TextWidgetComponent } from './text.widget';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatInputHarness } from '@angular/material/input/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('TextWidgetComponent', () => {
|
||||
const form = new FormModel({ taskId: 'fake-task-id' });
|
||||
@@ -37,7 +37,7 @@ describe('TextWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, TextWidgetComponent]
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, TextWidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TextWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
|
@@ -24,9 +24,9 @@ export interface LangChangeEvent {
|
||||
translations: any;
|
||||
}
|
||||
|
||||
/** @deprecated use `NoopTranslateModule` instead */
|
||||
@Injectable()
|
||||
export class TranslationMock implements TranslationService {
|
||||
|
||||
defaultLang: string = 'en';
|
||||
userLang: string;
|
||||
customLoader: any;
|
||||
@@ -50,5 +50,4 @@ export class TranslationMock implements TranslationService {
|
||||
instant(key: string | Array<string>): string | any {
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,14 +20,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatSnackBarConfig, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { NotificationService } from './notification.service';
|
||||
import { TranslationService } from '../../translation/translation.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatIconHarness } from '@angular/material/icon/testing';
|
||||
import {MatSnackBarHarness} from '@angular/material/snack-bar/testing';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { TranslationMock } from '../../mock';
|
||||
import { MatSnackBarHarness } from '@angular/material/snack-bar/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
@@ -94,10 +92,8 @@ describe('NotificationService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, HttpClientModule, MatSnackBarModule],
|
||||
declarations: [ProvidesNotificationServiceComponent],
|
||||
providers:[
|
||||
{ provide: TranslationService, useClass: TranslationMock }]
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, MatSnackBarModule],
|
||||
declarations: [ProvidesNotificationServiceComponent]
|
||||
});
|
||||
translationService = TestBed.inject(TranslationService);
|
||||
fixture = TestBed.createComponent(ProvidesNotificationServiceComponent);
|
||||
|
@@ -19,13 +19,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PaginationComponent } from './pagination.component';
|
||||
import { PaginatedComponent } from './paginated-component.interface';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { TranslateFakeLoader, TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
import { TranslationService } from '../translation/translation.service';
|
||||
import { TranslationMock } from '../mock/translation.service.mock';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
class FakePaginationInput implements PaginationModel {
|
||||
count = 25;
|
||||
@@ -46,17 +42,7 @@ describe('PaginationComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
HttpClientModule,
|
||||
MatMenuModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {provide: TranslateLoader, useClass: TranslateFakeLoader}
|
||||
})
|
||||
],
|
||||
providers:[
|
||||
{ provide: TranslationService, useClass: TranslationMock }
|
||||
]
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, PaginationComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(PaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
@@ -68,7 +54,7 @@ describe('PaginationComponent', () => {
|
||||
});
|
||||
|
||||
it('should have an "empty" class if no items present', async () => {
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(fixture.nativeElement.classList.contains('adf-pagination__empty')).toBeTruthy();
|
||||
|
@@ -18,14 +18,11 @@
|
||||
import { NgModule, APP_INITIALIZER } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CoreModule } from '../core.module';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AppConfigServiceMock } from '../common/mock/app-config.service.mock';
|
||||
import { TranslationService } from '../translation/translation.service';
|
||||
import { TranslationMock } from '../mock/translation.service.mock';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { CookieService } from '../common/services/cookie.service';
|
||||
import { CookieServiceMock } from '../mock/cookie.service.mock';
|
||||
@@ -34,6 +31,7 @@ import { directionalityConfigFactory } from '../common/services/directionality-c
|
||||
import { DirectionalityConfigService } from '../common/services/directionality-config.service';
|
||||
import { AuthModule, RedirectAuthService } from '../auth';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { NoopTranslateModule } from './noop-translate.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -41,14 +39,13 @@ import { EMPTY, of } from 'rxjs';
|
||||
NoopAnimationsModule,
|
||||
RouterTestingModule,
|
||||
HttpClientModule,
|
||||
TranslateModule.forRoot(),
|
||||
CoreModule.forRoot()
|
||||
CoreModule.forRoot(),
|
||||
NoopTranslateModule
|
||||
],
|
||||
providers: [
|
||||
DatePipe,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
{ provide: TranslationService, useClass: TranslationMock },
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
@@ -58,6 +55,6 @@ import { EMPTY, of } from 'rxjs';
|
||||
},
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, init: () => {}, onTokenReceived: of() } }
|
||||
],
|
||||
exports: [NoopAnimationsModule, CoreModule, TranslateModule, RouterTestingModule]
|
||||
exports: [NoopAnimationsModule, CoreModule, RouterTestingModule]
|
||||
})
|
||||
export class CoreTestingModule {}
|
||||
|
@@ -18,3 +18,4 @@
|
||||
export * from './setup-test-bed';
|
||||
export * from './core.testing.module';
|
||||
export * from './core.story.module';
|
||||
export * from './noop-translate.module';
|
||||
|
53
lib/core/src/lib/testing/noop-translate.module.ts
Normal file
53
lib/core/src/lib/testing/noop-translate.module.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EventEmitter, NgModule } from '@angular/core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { TranslationService } from '../translation/translation.service';
|
||||
import { LangChangeEvent } from '../mock';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
export class NoopTranslationService implements TranslationService {
|
||||
defaultLang: string = 'en';
|
||||
userLang: string;
|
||||
customLoader: any;
|
||||
|
||||
translate: any = {
|
||||
onLangChange: new EventEmitter<LangChangeEvent>()
|
||||
};
|
||||
|
||||
addTranslationFolder() {}
|
||||
onTranslationChanged() {}
|
||||
use(): any {}
|
||||
loadTranslation() {}
|
||||
|
||||
get(key: string | Array<string>): Observable<string | any> {
|
||||
return of(key);
|
||||
}
|
||||
|
||||
instant(key: string | Array<string>): string | any {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [HttpClientTestingModule, TranslateModule.forRoot()],
|
||||
providers: [{ provide: TranslationService, useClass: NoopTranslationService }],
|
||||
exports: [TranslateModule]
|
||||
})
|
||||
export class NoopTranslateModule {}
|
@@ -19,6 +19,8 @@ import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TxtViewerComponent } from './txt-viewer.component';
|
||||
import { CoreTestingModule } from '../../../testing';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Text View component', () => {
|
||||
let component: TxtViewerComponent;
|
||||
@@ -27,41 +29,42 @@ describe('Text View component', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule]
|
||||
imports: [CoreTestingModule, TxtViewerComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TxtViewerComponent);
|
||||
|
||||
const httpClient = TestBed.inject(HttpClient);
|
||||
spyOn(httpClient, 'get').and.returnValue(of('example'));
|
||||
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('View', () => {
|
||||
it('Should text container be present with urlFile', (done) => {
|
||||
it('Should text container be present with urlFile', async () => {
|
||||
fixture.detectChanges();
|
||||
const urlFile = './fake-test-file.txt';
|
||||
const change = new SimpleChange(null, urlFile, true);
|
||||
|
||||
component.ngOnChanges({ urlFile: change }).then(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('.adf-txt-viewer-content').textContent).toContain('example');
|
||||
done();
|
||||
});
|
||||
});
|
||||
await component.ngOnChanges({ urlFile: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('.adf-txt-viewer-content').textContent).toContain('example');
|
||||
});
|
||||
|
||||
it('Should text container be present with Blob file', (done) => {
|
||||
it('Should text container be present with Blob file', async () => {
|
||||
const blobFile = new Blob(['text example'], { type: 'text/txt' });
|
||||
|
||||
const change = new SimpleChange(null, blobFile, true);
|
||||
|
||||
component.ngOnChanges({ blobFile: change }).then(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('.adf-txt-viewer-content').textContent).toContain('example');
|
||||
done();
|
||||
});
|
||||
});
|
||||
await component.ngOnChanges({ blobFile: change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('.adf-txt-viewer-content').textContent).toContain('example');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user