mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-36260 global test setup (#10970)
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { BreadcrumbItemComponent } from '../components/breadcrumb-item/breadcrumb-item.component';
|
||||
import { BreadcrumbComponent } from '../components/breadcrumb/breadcrumb.component';
|
||||
import { NgIf } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-demo-breadcrumb',
|
||||
@@ -56,7 +62,8 @@ import { Component } from '@angular/core';
|
||||
</adf-breadcrumb-item>
|
||||
</adf-breadcrumb>
|
||||
`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [MatButtonModule, MatMenuModule, MatIconModule, BreadcrumbItemComponent, BreadcrumbComponent, NgIf]
|
||||
})
|
||||
export class DemoBreadcrumbComponent {
|
||||
compact = false;
|
||||
|
@@ -16,21 +16,19 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { FlagsComponent } from './flags.component';
|
||||
import { FeaturesDirective } from '../../directives/features.directive';
|
||||
import { WritableFeaturesServiceToken } from '../../interfaces/features.interface';
|
||||
import { provideMockFeatureFlags } from '../../mocks/features-service-mock.factory';
|
||||
import { StorageFeaturesService } from '../../services/storage-features.service';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('FlagsComponent', () => {
|
||||
let component: FlagsComponent;
|
||||
let fixture: ComponentFixture<FlagsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [FlagsComponent, NoopTranslateModule, FeaturesDirective, NoopAnimationsModule],
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [FlagsComponent, FeaturesDirective],
|
||||
providers: [
|
||||
{ provide: WritableFeaturesServiceToken, useClass: StorageFeaturesService },
|
||||
provideMockFeatureFlags({
|
||||
@@ -39,7 +37,7 @@ describe('FlagsComponent', () => {
|
||||
feature3: true
|
||||
})
|
||||
]
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
const storageFeaturesService = TestBed.inject(WritableFeaturesServiceToken);
|
||||
storageFeaturesService.init();
|
||||
|
@@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideMockFeatureFlags } from '../mocks/features-service-mock.factory';
|
||||
@@ -28,7 +27,8 @@ import { UnitTestingUtils } from '../../../../src/lib/testing/unit-testing-utils
|
||||
<div id="underFeatureFlag" *adfForFeatures="features"></div>
|
||||
</div>
|
||||
`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [FeaturesDirective]
|
||||
})
|
||||
class TestWithEnabledFlagComponent {
|
||||
features = 'feature1';
|
||||
@@ -39,7 +39,8 @@ class TestWithEnabledFlagComponent {
|
||||
<div id="underFeatureFlag" *adfForFeatures="features"></div>
|
||||
</div>
|
||||
`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [FeaturesDirective]
|
||||
})
|
||||
class TestWithDisabledFlagComponent {
|
||||
features = ['feature1', 'feature2'];
|
||||
@@ -52,7 +53,7 @@ describe('FeaturesDirective', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FeaturesDirective],
|
||||
imports: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent],
|
||||
providers: [
|
||||
provideMockFeatureFlags({
|
||||
feature1: true,
|
||||
@@ -60,8 +61,7 @@ describe('FeaturesDirective', () => {
|
||||
feature3: true
|
||||
}),
|
||||
FeaturesDirective
|
||||
],
|
||||
declarations: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent]
|
||||
]
|
||||
});
|
||||
enabledFixture = TestBed.createComponent(TestWithEnabledFlagComponent);
|
||||
enabledFixture.detectChanges();
|
||||
|
@@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideMockFeatureFlags } from '../mocks/features-service-mock.factory';
|
||||
@@ -28,7 +27,7 @@ import { UnitTestingUtils } from '../../../../src/lib/testing/unit-testing-utils
|
||||
<div id="underFeatureFlag" *adfNotForFeatures="features"></div>
|
||||
</div>
|
||||
`,
|
||||
standalone: false
|
||||
imports: [NotFeaturesDirective]
|
||||
})
|
||||
class TestWithEnabledFlagComponent {
|
||||
features = ['feature1', 'feature3'];
|
||||
@@ -40,7 +39,7 @@ class TestWithEnabledFlagComponent {
|
||||
<div id="underFeatureFlag" *adfNotForFeatures="features"></div>
|
||||
</div>
|
||||
`,
|
||||
standalone: false
|
||||
imports: [NotFeaturesDirective]
|
||||
})
|
||||
class TestWithDisabledFlagComponent {
|
||||
features = 'feature2';
|
||||
@@ -53,7 +52,7 @@ describe('NotFeaturesDirective', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NotFeaturesDirective],
|
||||
imports: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent],
|
||||
providers: [
|
||||
provideMockFeatureFlags({
|
||||
feature1: true,
|
||||
@@ -61,8 +60,7 @@ describe('NotFeaturesDirective', () => {
|
||||
feature3: true
|
||||
}),
|
||||
NotFeaturesDirective
|
||||
],
|
||||
declarations: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent]
|
||||
]
|
||||
});
|
||||
enabledFixture = TestBed.createComponent(TestWithEnabledFlagComponent);
|
||||
enabledFixture.detectChanges();
|
||||
|
@@ -15,18 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { AppConfigService, LAYOUT_DIRECTIVES } from '@alfresco/adf-core';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { ShellLayoutComponent } from './shell.component';
|
||||
import { Router, NavigationStart, RouterModule } from '@angular/router';
|
||||
import { of, Subject } from 'rxjs';
|
||||
import { ExtensionsModule } from '@alfresco/adf-extensions';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ShellAppService, SHELL_APP_SERVICE } from '../../services/shell-app.service';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
class MockRouter {
|
||||
private url = 'some-url';
|
||||
@@ -58,16 +52,7 @@ describe('AppLayoutComponent', () => {
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
NoopAnimationsModule,
|
||||
HttpClientModule,
|
||||
...LAYOUT_DIRECTIVES,
|
||||
ExtensionsModule,
|
||||
RouterModule.forChild([]),
|
||||
TranslateModule.forRoot(),
|
||||
ShellLayoutComponent
|
||||
],
|
||||
imports: [RouterModule.forChild([]), ShellLayoutComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: Router,
|
||||
@@ -77,8 +62,7 @@ describe('AppLayoutComponent', () => {
|
||||
provide: SHELL_APP_SERVICE,
|
||||
useValue: shellService
|
||||
}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(ShellLayoutComponent);
|
||||
|
@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AboutServerSettingsComponent } from './about-server-settings.component';
|
||||
import { AppConfigService } from '../../app-config/app-config.service';
|
||||
import { AppConfigServiceMock } from '../../common';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
|
||||
const aboutGithubDetails = {
|
||||
url: 'https://github.com/componany/repository/commits/',
|
||||
@@ -37,7 +36,6 @@ describe('AboutServerSettingsComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||
});
|
||||
fixture = TestBed.createComponent(AboutServerSettingsComponent);
|
||||
|
@@ -26,7 +26,6 @@ import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
|
||||
import { AuthGuardService } from './auth-guard.service';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
|
||||
describe('AuthGuardService BPM', () => {
|
||||
let authGuard: Promise<boolean>;
|
||||
@@ -41,7 +40,7 @@ describe('AuthGuardService BPM', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule],
|
||||
imports: [MatDialogModule],
|
||||
providers: [
|
||||
AuthGuardService,
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
|
||||
|
@@ -26,8 +26,6 @@ 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 '../../testing/noop-translate.module';
|
||||
|
||||
|
||||
describe('AuthGuardService ECM', () => {
|
||||
let authGuard: Promise<boolean>;
|
||||
@@ -41,7 +39,7 @@ describe('AuthGuardService ECM', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, RouterTestingModule, MatDialogModule],
|
||||
imports: [RouterTestingModule, MatDialogModule],
|
||||
providers: [
|
||||
BasicAlfrescoAuthService,
|
||||
AppConfigService,
|
||||
|
@@ -20,7 +20,6 @@ import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/ro
|
||||
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
|
||||
import { JwtHelperService } from '../services/jwt-helper.service';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { AuthModule } from '../oidc/auth.module';
|
||||
|
||||
describe('Auth Guard SSO role service', () => {
|
||||
@@ -30,7 +29,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule, AuthModule.forRoot({ useHash: true })]
|
||||
imports: [MatDialogModule, AuthModule.forRoot({ useHash: true })]
|
||||
});
|
||||
localStorage.clear();
|
||||
jwtHelperService = TestBed.inject(JwtHelperService);
|
||||
|
@@ -27,7 +27,6 @@ import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { NoopAuthModule } from '../../testing';
|
||||
|
||||
describe('AuthGuardService', () => {
|
||||
@@ -43,7 +42,7 @@ describe('AuthGuardService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule, NoopAuthModule],
|
||||
imports: [MatDialogModule, RouterTestingModule, NoopAuthModule],
|
||||
providers: [
|
||||
AppConfigService,
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of(), init: () => {} } },
|
||||
|
@@ -51,8 +51,7 @@ export function oauthStorageFactory(): OAuthStorage {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [AuthenticationConfirmationComponent],
|
||||
imports: [AuthRoutingModule, OAuthModule.forRoot()],
|
||||
imports: [AuthRoutingModule, OAuthModule.forRoot(), AuthenticationConfirmationComponent],
|
||||
providers: [
|
||||
{ provide: OAuthStorage, useFactory: oauthStorageFactory },
|
||||
{ provide: AuthenticationService },
|
||||
|
@@ -19,8 +19,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: '<div data-automation-id="auth-confirmation"></div>',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
standalone: false
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class AuthenticationConfirmationComponent {
|
||||
constructor() {}
|
||||
|
@@ -29,7 +29,6 @@ import { OAuthEvent } from 'angular-oauth2-oidc';
|
||||
import { firstValueFrom, of, Subject, throwError } from 'rxjs';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
import { Injector } from '@angular/core';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { ContentAuth, ProcessAuth } from '../public-api';
|
||||
|
||||
declare let jasmine: any;
|
||||
@@ -45,7 +44,7 @@ describe('AuthenticationService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, AuthModule.forRoot({ useHash: true })],
|
||||
imports: [AuthModule.forRoot({ useHash: true })],
|
||||
providers: [
|
||||
{
|
||||
provide: CookieService,
|
||||
|
@@ -28,7 +28,6 @@ import {
|
||||
roleMappingMock
|
||||
} from '../mock/identity-group.mock';
|
||||
import { AdfHttpClient } from '../../../../api/src';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
|
||||
describe('IdentityGroupService', () => {
|
||||
let service: IdentityGroupService;
|
||||
@@ -37,7 +36,6 @@ describe('IdentityGroupService', () => {
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [AdfHttpClient]
|
||||
});
|
||||
service = TestBed.inject(IdentityGroupService);
|
||||
|
@@ -34,7 +34,6 @@ import { mockToken } from '../mock/jwt-helper.service.spec';
|
||||
import { IdentityRoleModel } from '../models/identity-role.model';
|
||||
import { AdfHttpClient } from '../../../../api/src';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { OAuthStorage } from 'angular-oauth2-oidc';
|
||||
|
||||
describe('IdentityUserService', () => {
|
||||
@@ -53,7 +52,6 @@ describe('IdentityUserService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [AdfHttpClient, { provide: OAuthStorage, useClass: StorageService }]
|
||||
});
|
||||
storageService = TestBed.inject(StorageService);
|
||||
|
@@ -22,7 +22,6 @@ import { CardViewArrayItemModel, CardViewArrayItem } from '../../models/card-vie
|
||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
|
||||
describe('CardViewArrayItemComponent', () => {
|
||||
@@ -49,7 +48,7 @@ describe('CardViewArrayItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, CardViewArrayItemComponent]
|
||||
imports: [CardViewArrayItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewArrayItemComponent);
|
||||
service = TestBed.inject(CardViewUpdateService);
|
||||
|
@@ -20,7 +20,6 @@ import { 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 { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
@@ -32,9 +31,6 @@ describe('CardViewBoolItemComponent', () => {
|
||||
let testingUtils: UnitTestingUtils;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewBoolItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.property = new CardViewBoolItemModel({
|
||||
|
@@ -26,9 +26,7 @@ import { MatDatetimepickerInputEvent } from '@mat-datetimepicker/core';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { addMinutes } from 'date-fns';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
describe('CardViewDateItemComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
@@ -39,7 +37,7 @@ describe('CardViewDateItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, CardViewDateItemComponent, NoopAnimationsModule]
|
||||
imports: [CardViewDateItemComponent]
|
||||
});
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
appConfigService.config.dateValues = {
|
||||
|
@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CardViewKeyValuePairsItemModel } from '../../models/card-view-keyvaluepairs.model';
|
||||
import { CardViewKeyValuePairsItemComponent } from './card-view-keyvaluepairsitem.component';
|
||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
@@ -35,7 +34,7 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, CardViewKeyValuePairsItemComponent]
|
||||
imports: [CardViewKeyValuePairsItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewKeyValuePairsItemComponent);
|
||||
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
|
||||
|
@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CardViewMapItemModel } from '../../models/card-view-mapitem.model';
|
||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { CardViewMapItemComponent } from './card-view-mapitem.component';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
|
||||
describe('CardViewMapItemComponent', () => {
|
||||
@@ -30,7 +29,7 @@ describe('CardViewMapItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, CardViewMapItemComponent]
|
||||
imports: [CardViewMapItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewMapItemComponent);
|
||||
service = TestBed.inject(CardViewUpdateService);
|
||||
|
@@ -22,9 +22,7 @@ import { of } from 'rxjs';
|
||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||
import { DebugElement } from '@angular/core';
|
||||
@@ -63,7 +61,7 @@ describe('CardViewSelectItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, CardViewSelectItemComponent]
|
||||
imports: [CardViewSelectItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewSelectItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -18,8 +18,6 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SelectFilterInputComponent } from './select-filter-input.component';
|
||||
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../../../../testing/noop-translate.module';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
describe('SelectFilterInputComponent', () => {
|
||||
@@ -45,7 +43,7 @@ describe('SelectFilterInputComponent', () => {
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, MatSelectModule, SelectFilterInputComponent],
|
||||
imports: [MatSelectModule, SelectFilterInputComponent],
|
||||
providers: [{ provide: MatSelect, useValue: mockMatSelect }]
|
||||
}).compileComponents();
|
||||
|
||||
|
@@ -30,9 +30,7 @@ import { CardViewItemValidator } from '../../interfaces/card-view-item-validator
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatInputHarness } from '@angular/material/input/testing';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
describe('CardViewTextItemComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
@@ -113,7 +111,7 @@ describe('CardViewTextItemComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, CardViewTextItemComponent]
|
||||
imports: [CardViewTextItemComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(CardViewTextItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -27,9 +27,7 @@ import { CardViewItemDispatcherComponent } from '../card-view-item-dispatcher/ca
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
|
||||
describe('CardViewComponent', () => {
|
||||
@@ -40,7 +38,7 @@ describe('CardViewComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, MatSnackBarModule, MatDialogModule, CardViewComponent]
|
||||
imports: [MatSnackBarModule, MatDialogModule, CardViewComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(CardViewComponent);
|
||||
|
@@ -20,19 +20,19 @@ import { ComponentFixture, TestBed, tick, fakeAsync } from '@angular/core/testin
|
||||
import { ClipboardService } from './clipboard.service';
|
||||
import { ClipboardDirective } from './clipboard.directive';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { NoopTranslateModule } from '../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
import { HarnessLoader, TestKey } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-test-component',
|
||||
template: `
|
||||
<button mat-button clipboard-notification="copy success" [adf-clipboard] [target]="ref">copy</button>
|
||||
<button mat-button clipboard-notification="copy success" [adf-clipboard]="" [target]="ref">copy</button>
|
||||
|
||||
<input #ref />
|
||||
`,
|
||||
standalone: false
|
||||
imports: [MatButtonModule, ClipboardDirective]
|
||||
})
|
||||
class TestTargetClipboardComponent {}
|
||||
|
||||
@@ -44,8 +44,7 @@ describe('ClipboardDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatSnackBarModule, ClipboardDirective],
|
||||
declarations: [TestTargetClipboardComponent]
|
||||
imports: [MatSnackBarModule, TestTargetClipboardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestTargetClipboardComponent);
|
||||
clipboardService = TestBed.inject(ClipboardService);
|
||||
@@ -73,9 +72,9 @@ describe('ClipboardDirective', () => {
|
||||
|
||||
describe('CopyClipboardDirective', () => {
|
||||
@Component({
|
||||
selector: 'adf-copy-conent-test-component',
|
||||
selector: 'adf-copy-content-test-component',
|
||||
template: `<span adf-clipboard="placeholder">{{ mockText }}</span>`,
|
||||
standalone: false
|
||||
imports: [ClipboardDirective]
|
||||
})
|
||||
class TestCopyClipboardComponent {
|
||||
mockText = 'text to copy';
|
||||
@@ -90,8 +89,7 @@ describe('CopyClipboardDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatSnackBarModule, ClipboardDirective],
|
||||
declarations: [TestCopyClipboardComponent]
|
||||
imports: [MatSnackBarModule, TestCopyClipboardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestCopyClipboardComponent);
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
|
@@ -19,7 +19,6 @@ 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 { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('ClipboardService', () => {
|
||||
let clipboardService: ClipboardService;
|
||||
@@ -28,7 +27,7 @@ describe('ClipboardService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatSnackBarModule]
|
||||
imports: [MatSnackBarModule]
|
||||
});
|
||||
clipboardService = TestBed.inject(ClipboardService);
|
||||
notificationService = TestBed.inject(NotificationService);
|
||||
|
@@ -21,7 +21,6 @@ import { CommentListComponent } from './comment-list.component';
|
||||
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 { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../testing/unit-testing-utils';
|
||||
|
||||
describe('CommentListComponent', () => {
|
||||
@@ -31,7 +30,6 @@ describe('CommentListComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_COMMENTS_SERVICE,
|
||||
|
@@ -22,8 +22,6 @@ import { CommentsServiceMock, commentsResponseMock } from './mocks/comments.serv
|
||||
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 { NoopTranslateModule } from '../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
import { MatError } from '@angular/material/form-field';
|
||||
import { CommentModel } from '../models';
|
||||
@@ -38,7 +36,7 @@ describe('CommentsComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, CommentsComponent],
|
||||
imports: [CommentsComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_COMMENTS_SERVICE,
|
||||
|
@@ -25,8 +25,7 @@ import { LogService } from './log.service';
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
providers: [LogService],
|
||||
standalone: false
|
||||
providers: [LogService]
|
||||
})
|
||||
class ProvidesLogComponent {
|
||||
constructor(public logService: LogService) {}
|
||||
@@ -62,8 +61,7 @@ describe('LogService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientModule],
|
||||
declarations: [ProvidesLogComponent],
|
||||
imports: [HttpClientModule, ProvidesLogComponent],
|
||||
providers: [LogService, AppConfigService]
|
||||
});
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService } from '../../app-config/app-config.service';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { NoopAuthModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('StorageService', () => {
|
||||
let storage: StorageService;
|
||||
@@ -29,7 +29,7 @@ describe('StorageService', () => {
|
||||
describe('with local storage and prefix', () => {
|
||||
beforeEach(async () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAuthModule]
|
||||
imports: [NoopAuthModule]
|
||||
});
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
storage = TestBed.inject(StorageService);
|
||||
@@ -122,7 +122,7 @@ describe('StorageService', () => {
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAuthModule]
|
||||
imports: [NoopAuthModule]
|
||||
});
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
storage = TestBed.inject(StorageService);
|
||||
|
@@ -21,7 +21,6 @@ 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 { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('UserPreferencesService', () => {
|
||||
const supportedPaginationSize = [5, 10, 15, 20];
|
||||
@@ -32,7 +31,6 @@ describe('UserPreferencesService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||
});
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
|
@@ -17,16 +17,16 @@
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { CONTEXT_MENU_DIRECTIVES } from './context-menu.module';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
import { ContextMenuDirective } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-test-component',
|
||||
template: ` <div id="target" [adf-context-menu]="actions" [adf-context-menu-enabled]="isEnabled"></div> `,
|
||||
standalone: false
|
||||
imports: [ContextMenuDirective]
|
||||
})
|
||||
class TestComponent {
|
||||
actions: any[] | (() => any[]);
|
||||
@@ -119,8 +119,7 @@ testCases.forEach((testCase) => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule, CONTEXT_MENU_DIRECTIVES],
|
||||
declarations: [TestComponent]
|
||||
imports: [CoreTestingModule, TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
fixture.componentInstance.isEnabled = false;
|
||||
|
@@ -17,7 +17,6 @@
|
||||
|
||||
import { ColumnsSearchFilterPipe } from './columns-search-filter.pipe';
|
||||
import { DataColumn } from '../../data/data-column.model';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
describe('ColumnsSeearchFilterPipe', () => {
|
||||
@@ -25,7 +24,7 @@ describe('ColumnsSeearchFilterPipe', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, ColumnsSearchFilterPipe],
|
||||
imports: [ColumnsSearchFilterPipe],
|
||||
providers: [ColumnsSearchFilterPipe]
|
||||
});
|
||||
|
||||
|
@@ -22,7 +22,6 @@ import { Observable, Subject } from 'rxjs';
|
||||
import { MatMenuTrigger } from '@angular/material/menu';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
|
||||
describe('ColumnsSelectorComponent', () => {
|
||||
@@ -40,7 +39,7 @@ describe('ColumnsSelectorComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, ColumnsSelectorComponent]
|
||||
imports: [ColumnsSelectorComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(ColumnsSelectorComponent);
|
||||
|
@@ -23,7 +23,6 @@ import { AppConfigService } from '../../../app-config';
|
||||
import { LOCALE_ID } from '@angular/core';
|
||||
import { registerLocaleData } from '@angular/common';
|
||||
import localePL from '@angular/common/locales/pl';
|
||||
import { NoopTranslateModule } from '../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
|
||||
let component: DateCellComponent;
|
||||
@@ -63,7 +62,7 @@ const checkDisplayedTooltip = (expectedTooltip: string) => {
|
||||
|
||||
const configureTestingModule = (providers: any[]) => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [DateCellComponent, NoopTranslateModule],
|
||||
imports: [DateCellComponent],
|
||||
providers
|
||||
});
|
||||
fixture = TestBed.createComponent(DateCellComponent);
|
||||
|
@@ -17,14 +17,11 @@
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { ConfirmDialogComponent } from './confirm.dialog';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
/** @deprecated use `ConfirmDialogComponent` directly instead of importing this module */
|
||||
@NgModule({
|
||||
declarations: [ConfirmDialogComponent],
|
||||
imports: [CommonModule, FormsModule, ReactiveFormsModule, TranslateModule, MatDialogModule, MatButtonModule],
|
||||
declarations: [],
|
||||
imports: [ConfirmDialogComponent],
|
||||
exports: [ConfirmDialogComponent]
|
||||
})
|
||||
export class ConfirmDialogModule {}
|
||||
|
@@ -18,8 +18,6 @@
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
||||
import { ConfirmDialogComponent } from './confirm.dialog';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../testing/unit-testing-utils';
|
||||
|
||||
describe('Confirm Dialog Component', () => {
|
||||
@@ -40,7 +38,7 @@ describe('Confirm Dialog Component', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatDialogModule, NoopAnimationsModule, NoopTranslateModule],
|
||||
imports: [MatDialogModule, ConfirmDialogComponent],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: data }
|
||||
|
@@ -16,8 +16,11 @@
|
||||
*/
|
||||
|
||||
import { Component, Inject, SecurityContext, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { NgIf } from '@angular/common';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
export interface ConfirmDialogComponentProps {
|
||||
title?: string;
|
||||
@@ -34,7 +37,8 @@ export interface ConfirmDialogComponentProps {
|
||||
styleUrls: ['./confirm.dialog.scss'],
|
||||
host: { class: 'adf-confirm-dialog' },
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [TranslatePipe, MatDialogModule, NgIf, MatButtonModule]
|
||||
})
|
||||
export class ConfirmDialogComponent {
|
||||
title: string;
|
||||
|
@@ -25,8 +25,8 @@ import { Component, inject } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-dummy-component',
|
||||
standalone: false
|
||||
template: ``,
|
||||
selector: 'adf-dummy-component'
|
||||
})
|
||||
class DummyComponent {
|
||||
data = inject(DIALOG_COMPONENT_DATA);
|
||||
@@ -56,13 +56,12 @@ describe('DialogComponent', () => {
|
||||
|
||||
const setupBeforeEach = (dialogOptions: DialogData = data) => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule],
|
||||
declarations: [DummyComponent],
|
||||
imports: [CoreTestingModule, DummyComponent],
|
||||
providers: [
|
||||
{ provide: MAT_DIALOG_DATA, useValue: dialogOptions },
|
||||
{ provide: MatDialogRef, useValue: dialogRef }
|
||||
]
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
dialogRef.close.calls.reset();
|
||||
fixture = TestBed.createComponent(DialogComponent);
|
||||
|
@@ -18,11 +18,13 @@
|
||||
import { Component, OnInit, OnChanges, Input } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { EditJsonDialogComponent, EditJsonDialogSettings } from './edit-json.dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-edit-json-dialog-storybook',
|
||||
template: `<button mat-raised-button (click)="openDialog()">Open dialog</button>`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [MatButtonModule]
|
||||
})
|
||||
export class EditJsonDialogStorybookComponent implements OnInit, OnChanges {
|
||||
@Input()
|
||||
|
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ComponentFixture, fakeAsync, flush, TestBed } from '@angular/core/testing';
|
||||
import { InfiniteSelectScrollDirective } from './infinite-select-scroll.directive';
|
||||
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
@@ -30,7 +30,8 @@ import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
{{ option.text }}
|
||||
</mat-option>
|
||||
</mat-select>`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [MatSelectModule, InfiniteSelectScrollDirective, CommonModule]
|
||||
})
|
||||
class TestComponent {
|
||||
options = new Array(50).fill({ text: 'dummy' });
|
||||
@@ -55,8 +56,7 @@ describe('InfiniteSelectScrollDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatSelectModule, NoopAnimationsModule, InfiniteSelectScrollDirective],
|
||||
declarations: [TestComponent]
|
||||
imports: [TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -18,11 +18,8 @@
|
||||
import { Component, ElementRef, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TooltipCardDirective } from './tooltip-card.directive';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Overlay, OverlayContainer, OverlayModule } from '@angular/cdk/overlay';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TooltipCardComponent } from './tooltip-card.component';
|
||||
|
||||
const IMAGE_URL = 'alfresco-logo.svg';
|
||||
|
||||
@@ -35,7 +32,8 @@ const IMAGE_URL = 'alfresco-logo.svg';
|
||||
[htmlContent]="'this is the <b>html</b> raw code'"
|
||||
class="test-component"
|
||||
></span>`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [TooltipCardDirective]
|
||||
})
|
||||
class TestComponent {
|
||||
@ViewChild(TooltipCardDirective, { static: true })
|
||||
@@ -53,21 +51,16 @@ describe('TooltipCardDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, OverlayModule, NoopAnimationsModule, TooltipCardDirective, TooltipCardComponent],
|
||||
declarations: [TestComponent]
|
||||
}).compileComponents();
|
||||
});
|
||||
imports: [OverlayModule, TestComponent]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
overlayService = TestBed.inject(Overlay);
|
||||
overlayContainer = TestBed.inject(OverlayContainer);
|
||||
overlay = overlayContainer.getContainerElement();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
it('should display tooltip-card on mouse enter', () => {
|
||||
fixture.detectChanges();
|
||||
|
@@ -23,8 +23,6 @@ import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { FormModel } from '../core/form.model';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../../testing/unit-testing-utils';
|
||||
|
||||
describe('AmountWidgetComponent', () => {
|
||||
@@ -35,7 +33,7 @@ describe('AmountWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, FormBaseModule]
|
||||
imports: [FormBaseModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(AmountWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -133,7 +131,7 @@ describe('AmountWidgetComponent - rendering', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, FormBaseModule]
|
||||
imports: [FormBaseModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(AmountWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -338,7 +336,7 @@ describe('AmountWidgetComponent settings', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, FormBaseModule],
|
||||
imports: [FormBaseModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ADF_AMOUNT_SETTINGS,
|
||||
|
@@ -26,8 +26,6 @@ import { addMinutes } from 'date-fns';
|
||||
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 { NoopTranslateModule } from '../../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../../testing/unit-testing-utils';
|
||||
|
||||
describe('DateTimeWidgetComponent', () => {
|
||||
@@ -39,15 +37,7 @@ describe('DateTimeWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopTranslateModule,
|
||||
NoopAnimationsModule,
|
||||
MatDialogModule,
|
||||
MatNativeDatetimeModule,
|
||||
MatDatepickerModule,
|
||||
MatDatetimepickerModule,
|
||||
DateTimeWidgetComponent
|
||||
]
|
||||
imports: [MatDialogModule, MatNativeDatetimeModule, MatDatepickerModule, MatDatetimepickerModule, DateTimeWidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(DateTimeWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
|
@@ -20,8 +20,7 @@ import { ContainerModel } from '../core/container.model';
|
||||
import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { FormFieldModel } from '../core/form-field.model';
|
||||
import { HeaderWidgetComponent } from './header.widget';
|
||||
import { NoopTranslateModule, UnitTestingUtils } from '../../../../testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { UnitTestingUtils } from '../../../../testing';
|
||||
|
||||
describe('HeaderWidgetComponent', () => {
|
||||
let component: HeaderWidgetComponent;
|
||||
@@ -30,7 +29,7 @@ describe('HeaderWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HeaderWidgetComponent, NoopTranslateModule, NoopAnimationsModule]
|
||||
imports: [HeaderWidgetComponent]
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -17,13 +17,11 @@
|
||||
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
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, TestBed } from '@angular/core/testing';
|
||||
import { NoopTranslateModule } from '../../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../../testing/unit-testing-utils';
|
||||
|
||||
describe('MultilineTextWidgetComponentComponent', () => {
|
||||
@@ -34,7 +32,7 @@ describe('MultilineTextWidgetComponentComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, MultilineTextWidgetComponentComponent]
|
||||
imports: [MultilineTextWidgetComponentComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(MultilineTextWidgetComponentComponent);
|
||||
widget = fixture.componentInstance;
|
||||
|
@@ -22,8 +22,6 @@ import { FormModel } from '../core/form.model';
|
||||
import { TextWidgetComponent } from './text.widget';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../../../../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../../../../testing/unit-testing-utils';
|
||||
|
||||
describe('TextWidgetComponent', () => {
|
||||
@@ -37,7 +35,7 @@ describe('TextWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, TextWidgetComponent]
|
||||
imports: [TextWidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TextWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
|
@@ -22,8 +22,6 @@ import { InfoDrawerComponent, InfoDrawerTabComponent } from './info-drawer.compo
|
||||
import { ESCAPE } from '@angular/cdk/keycodes';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
|
||||
describe('InfoDrawerComponent', () => {
|
||||
@@ -33,7 +31,7 @@ describe('InfoDrawerComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, InfoDrawerComponent]
|
||||
imports: [InfoDrawerComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(InfoDrawerComponent);
|
||||
@@ -105,7 +103,7 @@ describe('Custom InfoDrawer', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, CustomInfoDrawerComponent]
|
||||
imports: [CustomInfoDrawerComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(CustomInfoDrawerComponent);
|
||||
@@ -174,7 +172,7 @@ describe('Header visibility InfoDrawer', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, VisibilityInfoDrawerComponent]
|
||||
imports: [VisibilityInfoDrawerComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(VisibilityInfoDrawerComponent);
|
||||
fixture.detectChanges();
|
||||
|
@@ -23,9 +23,7 @@ import { SidenavLayoutContentDirective } from '../../directives/sidenav-layout-c
|
||||
import { SidenavLayoutHeaderDirective } from '../../directives/sidenav-layout-header.directive';
|
||||
import { SidenavLayoutNavigationDirective } from '../../directives/sidenav-layout-navigation.directive';
|
||||
import { UserPreferencesService } from '../../../common/services/user-preferences.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { of } from 'rxjs';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
|
||||
@Component({
|
||||
@@ -54,14 +52,14 @@ import { UnitTestingUtils } from '../../../testing/unit-testing-utils';
|
||||
export class SidenavLayoutTesterComponent {}
|
||||
|
||||
describe('SidenavLayoutComponent', () => {
|
||||
let fixture: ComponentFixture<any>;
|
||||
let fixture: ComponentFixture<SidenavLayoutComponent>;
|
||||
let mediaQueryList: any;
|
||||
let component: SidenavLayoutComponent;
|
||||
let mediaMatcher: MediaMatcher;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NoopAnimationsModule, SidenavLayoutComponent],
|
||||
imports: [SidenavLayoutComponent],
|
||||
providers: [MediaMatcher, { provide: UserPreferencesService, useValue: { select: () => of() } }]
|
||||
});
|
||||
mediaQueryList = {
|
||||
@@ -82,10 +80,7 @@ describe('SidenavLayoutComponent', () => {
|
||||
component.sidenavMax = 320;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
describe('toggleMenu', () => {
|
||||
beforeEach(() => {
|
||||
@@ -160,7 +155,7 @@ describe('Template transclusion', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NoopAnimationsModule, SidenavLayoutTesterComponent],
|
||||
imports: [SidenavLayoutTesterComponent],
|
||||
providers: [MediaMatcher, { provide: UserPreferencesService, useValue: { select: () => of() } }]
|
||||
});
|
||||
|
||||
|
@@ -22,8 +22,6 @@ import { NotificationService } from '../services/notification.service';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { NOTIFICATION_TYPE, NotificationModel } from '../models/notification.model';
|
||||
import { UnitTestingUtils } from '../../testing/unit-testing-utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { NoopAuthModule } from '../../testing/noop-auth.module';
|
||||
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
||||
|
||||
@@ -43,7 +41,7 @@ describe('Notification History Component', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, NoopAuthModule, NotificationHistoryComponent, MatIconTestingModule]
|
||||
imports: [NoopAuthModule, NotificationHistoryComponent, MatIconTestingModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(NotificationHistoryComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -17,14 +17,12 @@
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatSnackBarConfig } from '@angular/material/snack-bar';
|
||||
import { MatSnackBarConfig, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { NotificationService } from './notification.service';
|
||||
import { TranslationService } from '../../translation/translation.service';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { provideNoopAnimations } from '@angular/platform-browser/animations';
|
||||
import { UnitTestingUtils } from '../../testing/unit-testing-utils';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
|
||||
@Component({
|
||||
template: '<div>Test div</div>',
|
||||
@@ -88,9 +86,8 @@ describe('NotificationService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ProvidesNotificationServiceComponent, NoopTranslateModule],
|
||||
providers: [provideNoopAnimations()]
|
||||
}).compileComponents();
|
||||
imports: [MatSnackBarModule, ProvidesNotificationServiceComponent]
|
||||
});
|
||||
translationService = TestBed.inject(TranslationService);
|
||||
fixture = TestBed.createComponent(ProvidesNotificationServiceComponent);
|
||||
fixture.detectChanges();
|
||||
|
@@ -27,7 +27,7 @@ import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
|
||||
@Component({
|
||||
template: ``,
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
class TestPaginatedComponent implements PaginatedComponent {
|
||||
private _pagination: BehaviorSubject<PaginationModel>;
|
||||
@@ -59,8 +59,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule],
|
||||
declarations: [TestPaginatedComponent]
|
||||
imports: [CoreTestingModule, TestPaginatedComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(InfinitePaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -20,8 +20,6 @@ import { PaginationComponent } from './pagination.component';
|
||||
import { PaginatedComponent } from './paginated-component.interface';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NoopTranslateModule } from '../testing/noop-translate.module';
|
||||
|
||||
class FakePaginationInput implements PaginationModel {
|
||||
count = 25;
|
||||
@@ -42,7 +40,7 @@ describe('PaginationComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, PaginationComponent]
|
||||
imports: [PaginationComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(PaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -16,9 +16,6 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { ProgressComponent } from './progress.component';
|
||||
@@ -30,10 +27,10 @@ describe('ProgressComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
let testingUtils: UnitTestingUtils;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [MatProgressBarModule, MatProgressSpinnerModule, NoopAnimationsModule, ProgressComponent]
|
||||
}).compileComponents();
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ProgressComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(ProgressComponent);
|
||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||
|
@@ -20,7 +20,6 @@ import { MatIcon } from '@angular/material/icon';
|
||||
import { MAT_SNACK_BAR_DATA, MatSnackBarRef } from '@angular/material/snack-bar';
|
||||
import { SnackbarContentComponent } from './snackbar-content.component';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
import { NoopTranslateModule } from '../testing/noop-translate.module';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
|
||||
describe('SnackbarContentComponent', () => {
|
||||
@@ -30,7 +29,7 @@ describe('SnackbarContentComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, CoreTestingModule, SnackbarContentComponent],
|
||||
imports: [CoreTestingModule, SnackbarContentComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: MatSnackBarRef,
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { of } from 'rxjs';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { EmptyContentComponent } from './empty-content.component';
|
||||
import { UnitTestingUtils } from '../../testing/unit-testing-utils';
|
||||
|
||||
@@ -43,7 +42,7 @@ describe('EmptyContentComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, TestComponent]
|
||||
imports: [TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
|
26
lib/core/src/lib/testing/global-testing.module.ts
Normal file
26
lib/core/src/lib/testing/global-testing.module.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 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 { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||
import { NoopTranslateModule } from './noop-translate.module';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
@NgModule({
|
||||
imports: [BrowserDynamicTestingModule, NoopTranslateModule, NoopAnimationsModule]
|
||||
})
|
||||
export class GlobalTestingModule {}
|
@@ -17,7 +17,6 @@
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ToolbarComponent } from './toolbar.component';
|
||||
import { NoopTranslateModule } from '../testing/noop-translate.module';
|
||||
import { UnitTestingUtils } from '../testing/unit-testing-utils';
|
||||
|
||||
describe('ToolbarComponent', () => {
|
||||
@@ -26,7 +25,7 @@ describe('ToolbarComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, ToolbarComponent]
|
||||
imports: [ToolbarComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(ToolbarComponent);
|
||||
|
@@ -15,59 +15,61 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { Injector } from '@angular/core';
|
||||
import { getTestBed, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { TranslateLoaderService } from './translate-loader.service';
|
||||
import { provideTranslations, TranslationService } from './translation.service';
|
||||
import { TranslationService } from './translation.service';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AppConfigServiceMock } from '../common/mock/app-config.service.mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('TranslationService', () => {
|
||||
let injector: Injector;
|
||||
let translationService: TranslationService;
|
||||
|
||||
class FakeLoader implements TranslateLoader {
|
||||
init = (): void => {
|
||||
// No implementation needed for this test
|
||||
};
|
||||
|
||||
setDefaultLang = (_lang: string): void => {
|
||||
// No implementation needed for this test
|
||||
};
|
||||
|
||||
getTranslation = (lang: string) => {
|
||||
const translations = {
|
||||
en: {
|
||||
TEST: 'This is a test',
|
||||
TEST2: 'This is another test'
|
||||
},
|
||||
fr: {
|
||||
TEST: 'This is a test',
|
||||
TEST2: 'This is another test'
|
||||
}
|
||||
};
|
||||
|
||||
return of(translations[lang]);
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderService
|
||||
useClass: FakeLoader
|
||||
}
|
||||
})
|
||||
],
|
||||
providers: [
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
provideTranslations('@alfresco/adf-core', 'assets/ng2-alfresco-core')
|
||||
]
|
||||
providers: [TranslationService, { provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||
});
|
||||
|
||||
jasmine.Ajax.install();
|
||||
|
||||
injector = getTestBed();
|
||||
translationService = injector.get(TranslationService);
|
||||
translationService.addTranslationFolder('fake-name', 'fake-path');
|
||||
translationService = TestBed.inject(TranslationService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should be able to get translations of the KEY: TEST', () => {
|
||||
it('should be able to get translations of the KEY: TEST', (done) => {
|
||||
translationService.get('TEST').subscribe((res: string) => {
|
||||
expect(res).toEqual('This is a test');
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ TEST: 'This is a test', TEST2: 'This is another test' })
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,12 +77,6 @@ describe('TranslationService', () => {
|
||||
translationService.get('TEST2').subscribe((res: string) => {
|
||||
expect(res).toEqual('This is another test');
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({ TEST: 'This is a test', TEST2: 'This is another test' })
|
||||
});
|
||||
});
|
||||
|
||||
it('should return empty string for missing key when getting instant translations', () => {
|
||||
|
@@ -23,7 +23,7 @@ import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { AppConfigService } from '../../../app-config';
|
||||
import { EventMock } from '../../../mock';
|
||||
import { NoopAuthModule, NoopTranslateModule, UnitTestingUtils } from '../../../testing';
|
||||
import { NoopAuthModule, UnitTestingUtils } from '../../../testing';
|
||||
import { RenderingQueueServices } from '../../services/rendering-queue.services';
|
||||
import { PdfThumbListComponent } from '../pdf-viewer-thumbnails/pdf-viewer-thumbnails.component';
|
||||
import { PDFJS_MODULE, PDFJS_VIEWER_MODULE, PdfViewerComponent } from './pdf-viewer.component';
|
||||
@@ -106,7 +106,7 @@ describe('Test PdfViewer component', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAuthModule, NoopTranslateModule, PdfViewerComponent],
|
||||
imports: [NoopAuthModule, PdfViewerComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: MatDialog,
|
||||
@@ -355,7 +355,7 @@ describe('Test PdfViewer - Zoom customization', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAuthModule, NoopTranslateModule, PdfViewerComponent],
|
||||
imports: [NoopAuthModule, PdfViewerComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: MatDialog,
|
||||
@@ -428,7 +428,7 @@ describe('Test PdfViewer - User interaction', () => {
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAuthModule, NoopTranslateModule, PdfViewerComponent],
|
||||
imports: [NoopAuthModule, PdfViewerComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: MatDialog,
|
||||
|
@@ -21,11 +21,10 @@ import { SpyLocation } from '@angular/common/testing';
|
||||
import { Component, DebugElement, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, DeferBlockBehavior, TestBed } from '@angular/core/testing';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { NoopTranslateModule, UnitTestingUtils } from '../../../testing';
|
||||
import { UnitTestingUtils } from '../../../testing';
|
||||
import { RenderingQueueServices } from '../../services/rendering-queue.services';
|
||||
import { ViewerRenderComponent } from './viewer-render.component';
|
||||
import { ImgViewerComponent, MediaPlayerComponent, PdfViewerComponent, ViewerExtensionDirective } from '@alfresco/adf-core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-double-viewer',
|
||||
@@ -69,7 +68,7 @@ describe('ViewerComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NoopAnimationsModule, MatDialogModule, ViewerRenderComponent, DoubleViewerComponent],
|
||||
imports: [MatDialogModule, ViewerRenderComponent, DoubleViewerComponent],
|
||||
providers: [RenderingQueueServices, { provide: Location, useClass: SpyLocation }, MatDialog],
|
||||
deferBlockBehavior: DeferBlockBehavior.Playthrough
|
||||
});
|
||||
|
@@ -39,7 +39,7 @@ import { ThumbnailService } from '../../common/services/thumbnail.service';
|
||||
@Component({
|
||||
selector: 'adf-dialog-dummy',
|
||||
template: ``,
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
class DummyDialogComponent {}
|
||||
|
||||
|
@@ -17,12 +17,12 @@
|
||||
|
||||
import 'zone.js';
|
||||
import 'zone.js/testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
import pdfjsLibMock from './src/lib/viewer/components/mock/pdfjs-lib.mock';
|
||||
import { GlobalTestingModule } from './src/lib/testing/global-testing.module';
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
|
||||
TestBed.initTestEnvironment(GlobalTestingModule, platformBrowserDynamicTesting(), {
|
||||
teardown: { destroyAfterEach: true }
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user