Files
alfresco-ng2-components/ng2-components/ng2-activiti-form/src/components/widgets/widget.component.spec.ts
2016-08-16 16:59:35 +01:00

56 lines
1.8 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 { it, describe, expect, beforeEach } from '@angular/core/testing';
import { WidgetComponent } from './widget.component';
import { FormFieldModel } from './core/form-field.model';
describe('WidgetComponent', () => {
let componentHandler;
beforeEach(() => {
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
});
it('should upgrade MDL content on view init', () => {
let component = new WidgetComponent();
component.ngAfterViewInit();
expect(componentHandler.upgradeAllRegistered).toHaveBeenCalled();
});
it('should setup MDL content only if component handler available', () => {
let component = new WidgetComponent();
expect(component.setupMaterialComponents()).toBeTruthy();
window['componentHandler'] = null;
expect(component.setupMaterialComponents()).toBeFalsy();
});
it('should check field', () => {
let component = new WidgetComponent();
expect(component.hasField()).toBeFalsy();
component.field = new FormFieldModel(null);
expect(component.hasField()).toBeTruthy();
});
});