Move test data from blocks to form mapper test to separate file

[MAILPOET-2609]
This commit is contained in:
Rostislav Wolny
2020-01-28 15:26:31 +01:00
committed by Pavel Dohnal
parent 1d7fffbe8d
commit ea99002b43
2 changed files with 182 additions and 196 deletions

View File

@@ -1,4 +1,167 @@
// eslint-disable-next-line import/prefer-default-export export const emailBlock = {
clientId: 'email',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/email-input',
attributes: {
label: 'Email Address',
labelWithinInput: false,
},
};
export const submitBlock = {
clientId: 'submit',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/submit-button',
attributes: {
label: 'Subscribe!',
},
};
export const segmentsBlock = {
clientId: 'segments',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/segment-select',
attributes: {
labelWithinInput: false,
mandatory: false,
label: 'Select list(s):',
values: [
{ id: '6', name: 'Unicorn Truthers' },
{ id: '24', name: 'Carrots are lit', isChecked: true },
{ id: '29', name: 'Daily' },
],
},
};
export const firstNameBlock = {
clientId: 'first_name',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/first-name-input',
attributes: {
label: 'First Name',
labelWithinInput: false,
mandatory: false,
},
};
export const lastNameBlock = {
clientId: 'last_name',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/last-name-input',
attributes: {
label: 'Last Name',
labelWithinInput: false,
mandatory: false,
},
};
export const customTextBlock = {
clientId: '2',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-text',
attributes: {
label: 'Name of the street',
labelWithinInput: false,
mandatory: false,
validate: 'alphanum',
customFieldId: 1,
},
};
export const customRadioBlock = {
clientId: '4',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-radio',
attributes: {
label: 'Options',
hideLabel: true,
mandatory: true,
customFieldId: 2,
values: [
{ name: 'option 1' },
{ name: 'option 2' },
],
},
};
export const customCheckBox = {
clientId: '5',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-checkbox',
attributes: {
label: 'Checkbox',
hideLabel: false,
mandatory: false,
customFieldId: 3,
values: [
{
name: 'Check this',
isChecked: true,
},
],
},
};
export const customSelectBlock = {
clientId: '5',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-select',
attributes: {
label: 'Select',
labelWithinInput: false,
mandatory: false,
customFieldId: 6,
values: [
{ name: 'option 1' },
{ name: 'option 2' },
],
},
};
export const customDateBlock = {
clientId: '5',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-date',
attributes: {
label: 'Date',
mandatory: false,
customFieldId: 6,
dateType: 'month_year',
dateFormat: 'MM/YYYY',
defaultToday: true,
},
};
export const dividerBlock = {
clientId: 'some_random_123',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/divider',
attributes: {},
};
export const customHtmlBlock = {
clientId: 'some_random_321',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/html',
attributes: {
content: 'HTML content',
nl2br: true,
},
};
export const nestedColumns = { export const nestedColumns = {
clientId: 'columns-1', clientId: 'columns-1',
name: 'core/columns', name: 'core/columns',
@@ -24,19 +187,7 @@ export const nestedColumns = {
name: 'core/column', name: 'core/column',
isValid: true, isValid: true,
attributes: {}, attributes: {},
innerBlocks: [ innerBlocks: [firstNameBlock],
{
clientId: 'first-name-1-1-1',
name: 'mailpoet-form/last-name-input',
isValid: true,
attributes: {
label: 'Last name',
labelWithinInput: true,
mandatory: true,
},
innerBlocks: [],
},
],
}, },
{ {
clientId: 'columns-1-1-2', clientId: 'columns-1-1-2',
@@ -47,13 +198,7 @@ export const nestedColumns = {
}, },
], ],
}, },
{ dividerBlock,
clientId: 'divider-1-1-2',
name: 'mailpoet-form/divider',
isValid: true,
attributes: {},
innerBlocks: [],
},
], ],
}, },
{ {
@@ -63,17 +208,7 @@ export const nestedColumns = {
attributes: { attributes: {
width: 33.33, width: 33.33,
}, },
innerBlocks: [ innerBlocks: [submitBlock],
{
clientId: 'submit-1-2',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/submit-button',
attributes: {
label: 'Subscribe!',
},
},
],
}, },
], ],
}; };

View File

@@ -1,169 +1,20 @@
import { expect } from 'chai'; import { expect } from 'chai';
import formBlocksToBody from '../../../../assets/js/src/form_editor/store/blocks_to_form_body.jsx'; import formBlocksToBody from '../../../../assets/js/src/form_editor/store/blocks_to_form_body.jsx';
import { nestedColumns } from './block_to_form_test_data.js'; import {
emailBlock,
const emailBlock = { lastNameBlock,
clientId: 'email', firstNameBlock,
isValid: true, submitBlock,
innerBlocks: [], segmentsBlock,
name: 'mailpoet-form/email-input', customTextBlock,
attributes: { customRadioBlock,
label: 'Email Address', customCheckBox,
labelWithinInput: false, customDateBlock,
}, customHtmlBlock,
}; customSelectBlock,
dividerBlock,
const submitBlock = { nestedColumns,
clientId: 'submit', } from './block_to_form_test_data.js';
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/submit-button',
attributes: {
label: 'Subscribe!',
},
};
const segmentsBlock = {
clientId: 'segments',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/segment-select',
attributes: {
labelWithinInput: false,
mandatory: false,
label: 'Select list(s):',
values: [
{ id: '6', name: 'Unicorn Truthers' },
{ id: '24', name: 'Carrots are lit', isChecked: true },
{ id: '29', name: 'Daily' },
],
},
};
const firstNameBlock = {
clientId: 'first_name',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/first-name-input',
attributes: {
label: 'First Name',
labelWithinInput: false,
mandatory: false,
},
};
const lastNameBlock = {
clientId: 'last_name',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/last-name-input',
attributes: {
label: 'Last Name',
labelWithinInput: false,
mandatory: false,
},
};
const customTextBlock = {
clientId: '2',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-text',
attributes: {
label: 'Name of the street',
labelWithinInput: false,
mandatory: false,
validate: 'alphanum',
customFieldId: 1,
},
};
const customRadioBlock = {
clientId: '4',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-radio',
attributes: {
label: 'Options',
hideLabel: true,
mandatory: true,
customFieldId: 2,
values: [
{ name: 'option 1' },
{ name: 'option 2' },
],
},
};
const customCheckBox = {
clientId: '5',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-checkbox',
attributes: {
label: 'Checkbox',
hideLabel: false,
mandatory: false,
customFieldId: 3,
values: [
{
name: 'Check this',
isChecked: true,
},
],
},
};
const customSelectBlock = {
clientId: '5',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-select',
attributes: {
label: 'Select',
labelWithinInput: false,
mandatory: false,
customFieldId: 6,
values: [
{ name: 'option 1' },
{ name: 'option 2' },
],
},
};
const customDateBlock = {
clientId: '5',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/custom-date',
attributes: {
label: 'Date',
mandatory: false,
customFieldId: 6,
dateType: 'month_year',
dateFormat: 'MM/YYYY',
defaultToday: true,
},
};
const dividerBlock = {
clientId: 'some_random_123',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/divider',
attributes: {},
};
const customHtmlBlock = {
clientId: 'some_random_321',
isValid: true,
innerBlocks: [],
name: 'mailpoet-form/html',
attributes: {
content: 'HTML content',
nl2br: true,
},
};
const checkBodyInputBasics = (input) => { const checkBodyInputBasics = (input) => {
expect(input.id).to.be.a('string'); expect(input.id).to.be.a('string');