ADF InfoDrawer the title and tabs label must be localized (#2454)

This commit is contained in:
Maurizio Vitale
2017-10-11 10:10:25 +01:00
committed by Eugenio Romano
parent 6f69f545ec
commit 2e0a6936aa
5 changed files with 61 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
<adf-info-drawer-layout>
<div *ngIf="title" info-drawer-title>Activities</div>
<div *ngIf="title" info-drawer-title>{{title}}</div>
<ng-content *ngIf="!title" info-drawer-title select="[info-drawer-title]"></ng-content>
<ng-content info-drawer-buttons select="[info-drawer-buttons]"></ng-content>

View File

@@ -15,8 +15,9 @@
* limitations under the License.
*/
import { DebugElement } from '@angular/core';
import { Component, DebugElement } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { MaterialModule } from '../../material.module';
import { InfoDrawerLayoutComponent } from './info-drawer-layout.component';
import { InfoDrawerComponent } from './info-drawer.component';
@@ -70,4 +71,53 @@ describe('InfoDrawerComponent', () => {
expect(tabEmitSpy).toHaveBeenCalled();
expect(tabEmitSpy).toHaveBeenCalledWith('DETAILS');
});
it('should render the title', () => {
component.title = 'FakeTitle';
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[info-drawer-title]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('FakeTitle');
});
});
@Component({
template: `
<adf-info-drawer>
<div info-drawer-title>Fake Title Custom</div>
</adf-info-drawer>
`
})
class CustomInfoDrawerComponent {
}
describe('Custom InfoDrawer', () => {
let fixture: ComponentFixture<CustomInfoDrawerComponent>;
let component: CustomInfoDrawerComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
InfoDrawerComponent,
InfoDrawerLayoutComponent,
CustomInfoDrawerComponent
],
imports: [
MaterialModule
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CustomInfoDrawerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should render the title', () => {
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[info-drawer-title]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('Fake Title Custom');
});
});