#1020 define a default value for layoutType

This commit is contained in:
mauriziovitale84 2016-11-14 12:07:04 +00:00 committed by Mario Romano
parent 55d73b8006
commit 2cb5987420
2 changed files with 14 additions and 1 deletions

View File

@ -67,6 +67,12 @@ describe('ActivitiApps', () => {
window['componentHandler'] = componentHandler;
});
it('should define layoutType with the default value', () => {
component.layoutType = '';
fixture.detectChanges();
expect(component.isGrid()).toBe(true);
});
it('should load apps on init', () => {
fixture.detectChanges();
expect(getAppsSpy).toHaveBeenCalled();

View File

@ -77,7 +77,7 @@ export class ActivitiApps implements OnInit {
ngOnInit() {
if (!this.isValidType()) {
throw( new Error(`LayoutType property allowed values: ${ActivitiApps.LAYOUT_LIST} - ${ActivitiApps.LAYOUT_GRID}`));
this.setDefaultLayoutType();
}
this.apps$.subscribe((app: any) => {
@ -136,6 +136,13 @@ export class ActivitiApps implements OnInit {
return false;
}
/**
* Assign the default value to LayoutType
*/
setDefaultLayoutType(): void {
this.layoutType = ActivitiApps.LAYOUT_GRID;
}
/**
* Return true if the layout type is LIST
* @returns {boolean}