mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-01 14:41:14 +00:00
[ACS-5540]fixed unit test cases and added unit test cases
This commit is contained in:
@@ -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<NodeAspectService>;
|
||||
|
||||
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<any>(),
|
||||
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<NodeAspectService>;
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
@@ -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');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user