Skip to content

Commit

Permalink
[ACS-8959] Introduce new takeUntilDestroyed operator where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikiwanekhyland committed Nov 18, 2024
1 parent db73509 commit cde9555
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export class PropertyGroupTranslatorService {
private userPreferenceService = inject(UserPreferencesService);
private appConfig = inject(AppConfigService);
private logService = inject(LogService);
private injector = inject(Injector);

valueSeparator: string;

private readonly injector = inject(Injector);

constructor() {
this.valueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ import {
import { FavoritePaging, FavoritePagingList, Node, NodeEntry, NodePaging } from '@alfresco/js-api';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { Component, CUSTOM_ELEMENTS_SCHEMA, QueryList, SimpleChange, SimpleChanges, ViewChild } from '@angular/core';
import {
Component,
CUSTOM_ELEMENTS_SCHEMA,
Injector,
QueryList,
runInInjectionContext,
SimpleChange,
SimpleChanges,
ViewChild
} from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
import { By } from '@angular/platform-browser';
Expand Down Expand Up @@ -84,6 +93,7 @@ describe('DocumentList', () => {
let spyFolder: any;
let spyFolderNode: any;
let authenticationService: AuthenticationService;
let injector: Injector;

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -106,6 +116,7 @@ describe('DocumentList', () => {
contentService = TestBed.inject(ContentService);
appConfigService = TestBed.inject(AppConfigService);
authenticationService = TestBed.inject(AuthenticationService);
injector = TestBed.inject(Injector);

spyFolder = spyOn(documentListService, 'getFolder').and.returnValue(of({ list: {} }));
spyFolderNode = spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry({ entry: new Node() })));
Expand Down Expand Up @@ -1126,7 +1137,9 @@ describe('DocumentList', () => {

it('should display [empty folder] template ', () => {
fixture.detectChanges();
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
runInInjectionContext(injector, () => {
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
})
expect(documentList.dataTable).toBeDefined();
expect(fixture.debugElement.query(By.css('adf-empty-list'))).not.toBeNull();
});
Expand All @@ -1145,7 +1158,9 @@ describe('DocumentList', () => {
});

it('should empty folder NOT show the pagination', () => {
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
runInInjectionContext(injector, () => {
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
})

expect(documentList.isEmpty()).toBeTruthy();
expect(element.querySelector('alfresco-pagination')).toBe(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';

@Directive()
// eslint-disable-next-line @angular-eslint/directive-class-suffix
// eslint-disable-next-line @typescript-eslint/brace-style
export abstract class BaseTaskListCloudComponent<T = unknown>
extends DataTableSchema<T>
implements OnChanges, AfterContentInit, PaginatedComponent, OnInit
{
// eslint-disable-next-line @typescript-eslint/brace-style
implements OnChanges, AfterContentInit, PaginatedComponent, OnInit {

@ContentChild(CustomEmptyContentTemplateDirective)
emptyCustomContent: CustomEmptyContentTemplateDirective;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ export class TaskDetailsComponent implements OnInit, OnChanges {
private peopleSearchObserver: Observer<LightUserRepresentation[]>;

constructor(
private taskListService: TaskListService,
private peopleProcessService: PeopleProcessService,
private cardViewUpdateService: CardViewUpdateService,
private dialog: MatDialog,
private destroyRef: DestroyRef
private readonly taskListService: TaskListService,
private readonly peopleProcessService: PeopleProcessService,
private readonly cardViewUpdateService: CardViewUpdateService,
private readonly dialog: MatDialog,
private readonly destroyRef: DestroyRef
) {}

ngOnInit() {
Expand Down

0 comments on commit cde9555

Please sign in to comment.