mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
* Aspects collection * Fetch only those metadata aspects which are defined in the application config * Aspect property filtering first round * Addig wildcard support for preset, default preset fallback to wildcard, and logging * Add white list service * Renaming services * ContentMetadataService and CardViewItemDispatcherComponent update * Observables... Observables everywhere... * Propers CardViewAspect * Defining more interfaces * Dummy data and expansions panels * Fix build attempt & proper panel expansion * Folder restructuring * Add different type mappings * Restructuring Card view component * Fix build * More ECM types supported * Validators first phase, extraction of interfaces, world domination preparation * Validators phase II. * Integer and float validators * Hide empty text items and validation message foundation * Validation error messages for text item view, small style changes * Update date item * bool item component * Datetimepicker npm module * Datetime model * Add mapping for datetime * Small fixes * Passing down preset * Adding forgotten package.json entry * Adding some tests for wrapper card component * content-metadata.component tests * Covering some edge cases, adding some tests * Fix cardview component's test * Add datetimepicker to demoshell * card view component show empty values by default * displayEmpty dependency injection * remove table like design from cardview * Using alfresco-js-api instead of spike * Remove spike folder and contents * Fix test * Cardview updated docs * Content metadata md * Fix review issues * Fix the packagr issue
173 lines
6.5 KiB
TypeScript
173 lines
6.5 KiB
TypeScript
/*!
|
|
* @license
|
|
* Copyright 2016 Alfresco Software, Ltd.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
/*tslint:disable: ban*/
|
|
|
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { By } from '@angular/platform-browser';
|
|
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
|
import { ContentMetadataCardComponent } from './content-metadata-card.component';
|
|
import { ContentMetadataComponent } from '../content-metadata/content-metadata.component';
|
|
import { MatExpansionModule, MatCardModule, MatButtonModule, MatIconModule } from '@angular/material';
|
|
import { ContentMetadataService } from '../../services/content-metadata.service';
|
|
import { BasicPropertiesService } from '../../services/basic-properties.service';
|
|
import { PropertyDescriptorLoaderService } from '../../services/properties-loader.service';
|
|
import { PropertyDescriptorsService } from '../../services/property-descriptors.service';
|
|
import { AspectWhiteListService } from '../../services/aspect-whitelist.service';
|
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
|
|
|
describe('ContentMetadataCardComponent', () => {
|
|
|
|
let component: ContentMetadataCardComponent,
|
|
fixture: ComponentFixture<ContentMetadataCardComponent>,
|
|
node: MinimalNodeEntryEntity,
|
|
preset = 'custom-preset';
|
|
|
|
beforeEach(async(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [
|
|
MatExpansionModule,
|
|
MatCardModule,
|
|
MatButtonModule,
|
|
MatIconModule
|
|
],
|
|
declarations: [
|
|
ContentMetadataCardComponent,
|
|
ContentMetadataComponent
|
|
],
|
|
providers: [
|
|
ContentMetadataService,
|
|
BasicPropertiesService,
|
|
PropertyDescriptorLoaderService,
|
|
PropertyDescriptorsService,
|
|
AspectWhiteListService,
|
|
AlfrescoApiService
|
|
]
|
|
}).compileComponents();
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(ContentMetadataCardComponent);
|
|
component = fixture.componentInstance;
|
|
node = <MinimalNodeEntryEntity> {
|
|
aspectNames: [],
|
|
content: {},
|
|
properties: {},
|
|
createdByUser: {},
|
|
modifiedByUser: {}
|
|
};
|
|
|
|
component.node = node;
|
|
component.preset = preset;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
TestBed.resetTestingModule();
|
|
});
|
|
|
|
it('should have displayEmpty input param as false by default', () => {
|
|
expect(component.displayEmpty).toBe(false);
|
|
});
|
|
|
|
it('should pass through the node to the underlying component', () => {
|
|
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
|
|
|
|
expect(contentMetadataComponent.node).toBe(node);
|
|
});
|
|
|
|
it('should pass through the preset to the underlying component', () => {
|
|
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
|
|
|
|
expect(contentMetadataComponent.preset).toBe(preset);
|
|
});
|
|
|
|
it('should pass through the preset to the underlying component', () => {
|
|
component.displayEmpty = true;
|
|
fixture.detectChanges();
|
|
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
|
|
|
|
expect(contentMetadataComponent.displayEmpty).toBe(true);
|
|
});
|
|
|
|
it('should pass through the editable to the underlying component', () => {
|
|
component.editable = true;
|
|
fixture.detectChanges();
|
|
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
|
|
|
|
expect(contentMetadataComponent.editable).toBe(true);
|
|
});
|
|
|
|
it('should pass through the expanded to the underlying component', () => {
|
|
component.expanded = true;
|
|
fixture.detectChanges();
|
|
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
|
|
|
|
expect(contentMetadataComponent.expanded).toBe(true);
|
|
});
|
|
|
|
it('should not show anything if node is not present', () => {
|
|
component.node = undefined;
|
|
fixture.detectChanges();
|
|
|
|
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent));
|
|
|
|
expect(contentMetadataComponent).toBeNull();
|
|
});
|
|
|
|
it('should toggle editable by clicking on the button', () => {
|
|
component.editable = true;
|
|
fixture.detectChanges();
|
|
|
|
const button = fixture.debugElement.query(By.css('[data-automation-id="mata-data-card-toggle-edit"]'));
|
|
button.triggerEventHandler('click', {});
|
|
fixture.detectChanges();
|
|
|
|
expect(component.editable).toBe(false);
|
|
});
|
|
|
|
it('should toggle expanded by clicking on the button', () => {
|
|
component.expanded = true;
|
|
fixture.detectChanges();
|
|
|
|
const button = fixture.debugElement.query(By.css('[data-automation-id="mata-data-card-toggle-expand"]'));
|
|
button.triggerEventHandler('click', {});
|
|
fixture.detectChanges();
|
|
|
|
expect(component.expanded).toBe(false);
|
|
});
|
|
|
|
it('should have the proper text on button while collapsed', () => {
|
|
component.expanded = false;
|
|
fixture.detectChanges();
|
|
|
|
const buttonLabel = fixture.debugElement.query(By.css('[data-automation-id="mata-data-card-toggle-expand-label"]'));
|
|
|
|
expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.MORE_INFORMATION');
|
|
});
|
|
|
|
it('should have the proper text on button while collapsed', () => {
|
|
component.expanded = true;
|
|
fixture.detectChanges();
|
|
|
|
const buttonLabel = fixture.debugElement.query(By.css('[data-automation-id="mata-data-card-toggle-expand-label"]'));
|
|
|
|
expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.LESS_INFORMATION');
|
|
});
|
|
});
|