From 3e435be1d0d1166b864d8678a25d9bc986680f4b Mon Sep 17 00:00:00 2001 From: Yasa-Nataliya Date: Fri, 1 Sep 2023 15:09:42 +0530 Subject: [PATCH] [ACS-5540]fixed unit test cases and added unit test cases --- .../details/details.component.spec.ts | 18 ++++++++++++++++-- .../metadata-tab.component.spec.ts | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/projects/aca-content/src/lib/components/details/details.component.spec.ts b/projects/aca-content/src/lib/components/details/details.component.spec.ts index 0988ca703..280dcbb88 100644 --- a/projects/aca-content/src/lib/components/details/details.component.spec.ts +++ b/projects/aca-content/src/lib/components/details/details.component.spec.ts @@ -31,10 +31,10 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Store } from '@ngrx/store'; import { ContentApiService } from '@alfresco/aca-shared'; import { STORE_INITIAL_APP_DATA, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; -import { NodeEntry } from '@alfresco/js-api'; +import { MinimalNodeEntryEntity, NodeEntry } from '@alfresco/js-api'; import { RouterTestingModule } from '@angular/router/testing'; import { AuthenticationService, PageTitleService } from '@alfresco/adf-core'; -import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; +import { NodeAspectService, SearchQueryBuilderService } from '@alfresco/adf-content-services'; describe('DetailsComponent', () => { let component: DetailsComponent; @@ -42,6 +42,7 @@ describe('DetailsComponent', () => { let contentApiService: ContentApiService; let store: Store; let node: NodeEntry; + let mockNodeAspectService: jasmine.SpyObj; const mockStream = new Subject(); const storeMock = { @@ -50,6 +51,7 @@ describe('DetailsComponent', () => { }; beforeEach(() => { + const nodeAspectServiceSpy = jasmine.createSpyObj('NodeAspectService', ['updateNodeAspects']); TestBed.configureTestingModule({ imports: [AppTestingModule, DetailsComponent], providers: [ @@ -78,6 +80,10 @@ describe('DetailsComponent', () => { onLogout: new Subject(), isLoggedIn: () => true } + }, + { + provide: NodeAspectService, + useValue: nodeAspectServiceSpy } ], schemas: [NO_ERRORS_SCHEMA] @@ -86,6 +92,8 @@ describe('DetailsComponent', () => { fixture = TestBed.createComponent(DetailsComponent); component = fixture.componentInstance; contentApiService = TestBed.inject(ContentApiService); + mockNodeAspectService = TestBed.inject(NodeAspectService) as jasmine.SpyObj; + component.node = { id: 'test-id' } as MinimalNodeEntryEntity; store = TestBed.inject(Store); node = { @@ -128,4 +136,10 @@ describe('DetailsComponent', () => { fixture.detectChanges(); expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node])); }); + + it('should call openAspectDialog and updateNodeAspects when the button is clicked', () => { + component.openAspectDialog(); + fixture.detectChanges(); + expect(mockNodeAspectService.updateNodeAspects).toHaveBeenCalledWith('test-id'); + }); }); diff --git a/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts b/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts index f990d7b3d..4d01789af 100644 --- a/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts +++ b/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts @@ -256,7 +256,7 @@ describe('MetadataTabComponent', () => { }); it('show pass empty when store is in initial state', () => { - const initialState = fixture.debugElement.query(By.css('adf-content-metadata-card')); + const initialState = fixture.debugElement.query(By.css('adf-content-metadata')); expect(initialState.componentInstance.displayAspect).toBeFalsy(); }); @@ -266,7 +266,7 @@ describe('MetadataTabComponent', () => { expect(aspect).toBe('EXIF'); }); fixture.detectChanges(); - const initialState = fixture.debugElement.query(By.css('adf-content-metadata-card')); + const initialState = fixture.debugElement.query(By.css('adf-content-metadata')); expect(initialState.componentInstance.displayAspect).toBe('EXIF'); }); });