mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[AAE-12134] unit test: Should be able to set number of columns for Header widget (#8267)
This commit is contained in:
parent
54bb8e24e5
commit
c5710c0e61
@ -47,7 +47,8 @@ import {
|
||||
cloudFormMock,
|
||||
conditionalUploadWidgetsMock,
|
||||
emptyFormRepresentationJSON,
|
||||
fakeCloudForm, fakeMetadataForm, multilingualForm
|
||||
fakeCloudForm, fakeMetadataForm, multilingualForm,
|
||||
formDefinitionThreeColumnMock
|
||||
} from '../mocks/cloud-form.mock';
|
||||
import { FormCloudRepresentation } from '../models/form-cloud-representation.model';
|
||||
import { FormCloudService } from '../services/form-cloud.service';
|
||||
@ -1056,6 +1057,26 @@ describe('FormCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should render header and three text field columns', () => {
|
||||
const formModel = formCloudService.parseForm(formDefinitionThreeColumnMock);
|
||||
formComponent.form = formModel;
|
||||
fixture.detectChanges();
|
||||
|
||||
const columns = fixture.debugElement.queryAll(By.css('.adf-grid-list-single-column'));
|
||||
|
||||
expect(columns.length).toEqual(3);
|
||||
columns.forEach(column => expect(column.styles.width).toEqual('33.3333%'));
|
||||
columns.forEach(column => {
|
||||
const input = column.query(By.css('input[matinput]'));
|
||||
expect(input.attributes.type).toEqual('text');
|
||||
});
|
||||
|
||||
const header = fixture.debugElement.query(By.css('#container-header'));
|
||||
expect(header.nativeElement.innerText).toEqual('Header');
|
||||
|
||||
expect(formComponent.showTitle).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('form validations', () => {
|
||||
it('should be able to set visibility conditions for Attach File widget', async () => {
|
||||
spyOn(formCloudService, 'getForm').and.returnValue(of(conditionalUploadWidgetsMock));
|
||||
|
@ -741,6 +741,90 @@ export const fakeCloudForm = {
|
||||
}
|
||||
};
|
||||
|
||||
export const formDefinitionThreeColumnMock = {
|
||||
formRepresentation: {
|
||||
id: 'form-358ea9b1-7a14-4066-8313-bd84f14e1dbb',
|
||||
name: 'HeaderColumns',
|
||||
description: '',
|
||||
version: 0,
|
||||
formDefinition: {
|
||||
tabs: [],
|
||||
fields: [
|
||||
{
|
||||
id: 'Header',
|
||||
name: 'Header',
|
||||
type: 'group',
|
||||
tab: null,
|
||||
params: {
|
||||
allowCollapse: false,
|
||||
collapseByDefault: false
|
||||
},
|
||||
numberOfColumns: 3,
|
||||
fields: {
|
||||
1: [
|
||||
{
|
||||
id: 'Text',
|
||||
name: 'Text',
|
||||
type: 'text',
|
||||
required: false,
|
||||
colspan: 1,
|
||||
placeholder: null,
|
||||
minLength: 0,
|
||||
maxLength: 0,
|
||||
regexPattern: null,
|
||||
visibilityCondition: null,
|
||||
params: {
|
||||
existingColspan: 1,
|
||||
maxColspan: 2
|
||||
}
|
||||
}
|
||||
],
|
||||
2: [
|
||||
{
|
||||
id: 'Text',
|
||||
name: 'Text',
|
||||
type: 'text',
|
||||
required: false,
|
||||
colspan: 1,
|
||||
placeholder: null,
|
||||
minLength: 0,
|
||||
maxLength: 0,
|
||||
regexPattern: null,
|
||||
visibilityCondition: null,
|
||||
params: {
|
||||
existingColspan: 1,
|
||||
maxColspan: 2
|
||||
}
|
||||
}
|
||||
],
|
||||
3: [
|
||||
{
|
||||
id: 'Text',
|
||||
name: 'Text',
|
||||
type: 'text',
|
||||
required: false,
|
||||
colspan: 1,
|
||||
placeholder: null,
|
||||
minLength: 0,
|
||||
maxLength: 0,
|
||||
regexPattern: null,
|
||||
visibilityCondition: null,
|
||||
params: {
|
||||
existingColspan: 1,
|
||||
maxColspan: 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
outcomes: [],
|
||||
metadata: {},
|
||||
variables: []
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const emptyFormRepresentationJSON = {
|
||||
description: '',
|
||||
fields: [],
|
||||
|
Loading…
x
Reference in New Issue
Block a user