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 { Store } from '@ngrx/store';
|
||||||
import { ContentApiService } from '@alfresco/aca-shared';
|
import { ContentApiService } from '@alfresco/aca-shared';
|
||||||
import { STORE_INITIAL_APP_DATA, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
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 { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { AuthenticationService, PageTitleService } from '@alfresco/adf-core';
|
import { AuthenticationService, PageTitleService } from '@alfresco/adf-core';
|
||||||
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
import { NodeAspectService, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
describe('DetailsComponent', () => {
|
describe('DetailsComponent', () => {
|
||||||
let component: DetailsComponent;
|
let component: DetailsComponent;
|
||||||
@@ -42,6 +42,7 @@ describe('DetailsComponent', () => {
|
|||||||
let contentApiService: ContentApiService;
|
let contentApiService: ContentApiService;
|
||||||
let store: Store;
|
let store: Store;
|
||||||
let node: NodeEntry;
|
let node: NodeEntry;
|
||||||
|
let mockNodeAspectService: jasmine.SpyObj<NodeAspectService>;
|
||||||
|
|
||||||
const mockStream = new Subject();
|
const mockStream = new Subject();
|
||||||
const storeMock = {
|
const storeMock = {
|
||||||
@@ -50,6 +51,7 @@ describe('DetailsComponent', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
const nodeAspectServiceSpy = jasmine.createSpyObj('NodeAspectService', ['updateNodeAspects']);
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AppTestingModule, DetailsComponent],
|
imports: [AppTestingModule, DetailsComponent],
|
||||||
providers: [
|
providers: [
|
||||||
@@ -78,6 +80,10 @@ describe('DetailsComponent', () => {
|
|||||||
onLogout: new Subject<any>(),
|
onLogout: new Subject<any>(),
|
||||||
isLoggedIn: () => true
|
isLoggedIn: () => true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: NodeAspectService,
|
||||||
|
useValue: nodeAspectServiceSpy
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
@@ -86,6 +92,8 @@ describe('DetailsComponent', () => {
|
|||||||
fixture = TestBed.createComponent(DetailsComponent);
|
fixture = TestBed.createComponent(DetailsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
contentApiService = TestBed.inject(ContentApiService);
|
contentApiService = TestBed.inject(ContentApiService);
|
||||||
|
mockNodeAspectService = TestBed.inject(NodeAspectService) as jasmine.SpyObj<NodeAspectService>;
|
||||||
|
component.node = { id: 'test-id' } as MinimalNodeEntryEntity;
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
|
|
||||||
node = {
|
node = {
|
||||||
@@ -128,4 +136,10 @@ describe('DetailsComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
|
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', () => {
|
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();
|
expect(initialState.componentInstance.displayAspect).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ describe('MetadataTabComponent', () => {
|
|||||||
expect(aspect).toBe('EXIF');
|
expect(aspect).toBe('EXIF');
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
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');
|
expect(initialState.componentInstance.displayAspect).toBe('EXIF');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user