mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
AAE-22947 Update form.model
This commit is contained in:
@@ -33,9 +33,7 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [CoreTestingModule]
|
||||||
CoreTestingModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
formService = new FormService();
|
formService = new FormService();
|
||||||
});
|
});
|
||||||
@@ -132,10 +130,7 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
it('should parse tabs', () => {
|
it('should parse tabs', () => {
|
||||||
const json = {
|
const json = {
|
||||||
tabs: [
|
tabs: [{ id: 'tab1' }, { id: 'tab2' }]
|
||||||
{ id: 'tab1' },
|
|
||||||
{ id: 'tab2' }
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const form = new FormModel(json);
|
const form = new FormModel(json);
|
||||||
@@ -199,10 +194,7 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
it('should put fields into corresponding tabs', () => {
|
it('should put fields into corresponding tabs', () => {
|
||||||
const json = {
|
const json = {
|
||||||
tabs: [
|
tabs: [{ id: 'tab1' }, { id: 'tab2' }],
|
||||||
{ id: 'tab1' },
|
|
||||||
{ id: 'tab2' }
|
|
||||||
],
|
|
||||||
fields: [
|
fields: [
|
||||||
{ id: 'field1', tab: 'tab1', type: FormFieldTypes.CONTAINER },
|
{ id: 'field1', tab: 'tab1', type: FormFieldTypes.CONTAINER },
|
||||||
{ id: 'field2', tab: 'tab2', type: FormFieldTypes.CONTAINER },
|
{ id: 'field2', tab: 'tab2', type: FormFieldTypes.CONTAINER },
|
||||||
@@ -227,9 +219,7 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
it('should create standard form outcomes', () => {
|
it('should create standard form outcomes', () => {
|
||||||
const json = {
|
const json = {
|
||||||
fields: [
|
fields: [{ id: 'container1' }]
|
||||||
{ id: 'container1' }
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const form = new FormModel(json);
|
const form = new FormModel(json);
|
||||||
@@ -255,12 +245,8 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
it('should use custom form outcomes', () => {
|
it('should use custom form outcomes', () => {
|
||||||
const json = {
|
const json = {
|
||||||
fields: [
|
fields: [{ id: 'container1' }],
|
||||||
{ id: 'container1' }
|
outcomes: [{ id: 'custom-1', name: 'custom 1' }]
|
||||||
],
|
|
||||||
outcomes: [
|
|
||||||
{ id: 'custom-1', name: 'custom 1' }
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const form = new FormModel(json);
|
const form = new FormModel(json);
|
||||||
@@ -276,9 +262,7 @@ describe('FormModel', () => {
|
|||||||
it('should raise validation event when validating form', () => {
|
it('should raise validation event when validating form', () => {
|
||||||
const form = new FormModel({}, null, false, formService);
|
const form = new FormModel({}, null, false, formService);
|
||||||
|
|
||||||
formService.validateForm.subscribe((validateFormEvent) =>
|
formService.validateForm.subscribe((validateFormEvent) => expect(validateFormEvent).toBeTruthy());
|
||||||
expect(validateFormEvent).toBeTruthy()
|
|
||||||
);
|
|
||||||
form.validateForm();
|
form.validateForm();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -286,9 +270,7 @@ describe('FormModel', () => {
|
|||||||
const form = new FormModel({}, null, false, formService);
|
const form = new FormModel({}, null, false, formService);
|
||||||
const field = jasmine.createSpyObj('FormFieldModel', ['validate']);
|
const field = jasmine.createSpyObj('FormFieldModel', ['validate']);
|
||||||
|
|
||||||
formService.validateFormField.subscribe((validateFormFieldEvent) =>
|
formService.validateFormField.subscribe((validateFormFieldEvent) => expect(validateFormFieldEvent).toBeTruthy());
|
||||||
expect(validateFormFieldEvent).toBeTruthy()
|
|
||||||
);
|
|
||||||
form.validateField(field);
|
form.validateField(field);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -587,8 +569,8 @@ describe('FormModel', () => {
|
|||||||
const values = {
|
const values = {
|
||||||
pfx_property_one: 'testValue',
|
pfx_property_one: 'testValue',
|
||||||
pfx_property_two: true,
|
pfx_property_two: true,
|
||||||
pfx_property_three: 'opt_1',
|
pfx_property_three: { id: 'opt_1', name: 'Option 1' },
|
||||||
pfx_property_four: 'option_2',
|
pfx_property_four: { id: 'option_2', name: 'Option: 2' },
|
||||||
pfx_property_five: 'orange',
|
pfx_property_five: 'orange',
|
||||||
pfx_property_six: 'other-value',
|
pfx_property_six: 'other-value',
|
||||||
pfx_property_none: 'no_form_field'
|
pfx_property_none: 'no_form_field'
|
||||||
@@ -604,7 +586,6 @@ describe('FormModel', () => {
|
|||||||
expect(form.values['pfx_property_six']).toEqual('text-value');
|
expect(form.values['pfx_property_six']).toEqual('text-value');
|
||||||
expect(form.values['pfx_property_seven']).toBeNull();
|
expect(form.values['pfx_property_seven']).toBeNull();
|
||||||
expect(form.values['pfx_property_eight']).toBeNull();
|
expect(form.values['pfx_property_eight']).toBeNull();
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user