mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
* add codelyzer in core and datatable * add codelyzer in the main build * order imports * fix import in test * fix import test * import reorder form * tasklist and processlist import reorder
100 lines
3.5 KiB
TypeScript
100 lines
3.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.
|
|
*/
|
|
|
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { By } from '@angular/platform-browser';
|
|
import { CardViewModel } from '../../models/card-view.model';
|
|
import { CardViewComponent } from './adf-card-view.component';
|
|
|
|
describe('AdfCardView', () => {
|
|
|
|
let fixture: ComponentFixture<CardViewComponent>;
|
|
let component: CardViewComponent;
|
|
|
|
beforeEach(async(() => {
|
|
TestBed.configureTestingModule({
|
|
declarations: [
|
|
CardViewComponent
|
|
],
|
|
providers: [
|
|
]
|
|
}).compileComponents();
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(CardViewComponent);
|
|
component = fixture.componentInstance;
|
|
});
|
|
|
|
it('should render the label and value', async(() => {
|
|
component.properties = [new CardViewModel({label: 'My label', value: 'My value'})];
|
|
fixture.detectChanges();
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
|
|
let labelValue = fixture.debugElement.query(By.css('.adf-header__label'));
|
|
expect(labelValue).not.toBeNull();
|
|
expect(labelValue.nativeElement.innerText).toBe('My label');
|
|
|
|
let value = fixture.debugElement.query(By.css('.adf-header__value'));
|
|
expect(value).not.toBeNull();
|
|
expect(value.nativeElement.innerText).toBe('My value');
|
|
});
|
|
|
|
}));
|
|
|
|
it('should render the date in the correct format', async(() => {
|
|
component.properties = [new CardViewModel({
|
|
label: 'My date label', value: '2017-06-14',
|
|
format: 'MMM DD YYYY'
|
|
})];
|
|
fixture.detectChanges();
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
|
|
let labelValue = fixture.debugElement.query(By.css('.adf-header__label'));
|
|
expect(labelValue).not.toBeNull();
|
|
expect(labelValue.nativeElement.innerText).toBe('My date label');
|
|
|
|
let value = fixture.debugElement.query(By.css('.adf-header__value'));
|
|
expect(value).not.toBeNull();
|
|
expect(value.nativeElement.innerText).toBe('Jun 14 2017');
|
|
});
|
|
|
|
}));
|
|
|
|
it('should render the default value if the value is empty', async(() => {
|
|
component.properties = [new CardViewModel({
|
|
label: 'My default label',
|
|
default: 'default value'
|
|
})];
|
|
fixture.detectChanges();
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
|
|
let labelValue = fixture.debugElement.query(By.css('.adf-header__label'));
|
|
expect(labelValue).not.toBeNull();
|
|
expect(labelValue.nativeElement.innerText).toBe('My default label');
|
|
|
|
let value = fixture.debugElement.query(By.css('.adf-header__value'));
|
|
expect(value).not.toBeNull();
|
|
expect(value.nativeElement.innerText).toBe('default value');
|
|
});
|
|
|
|
}));
|
|
});
|