diff --git a/test/logic/generateFilterdata/Subform.test.js b/test/logic/generateFilterdata/Subform.test.js new file mode 100644 index 0000000..1f2e086 --- /dev/null +++ b/test/logic/generateFilterdata/Subform.test.js @@ -0,0 +1,14 @@ +import { describe, assert, expect, test, beforeEach, beforeAll } from 'vitest' +import { generateIfFilterOptionsData } from '@ER/formEditor/components/Panels/Config/components/generateFilterdata.js' +import _ from 'lodash-es' +import erGeneratorData from '@ER/formEditor/generatorData.js' +import * as erComponentsConfig from '@ER/formEditor/componentsConfig.js' +describe('Generate filter data: Subform', () => { + let testData = {} + beforeAll(() => { + testData = erGeneratorData(_.cloneDeep(erComponentsConfig.fieldsConfig[2].list[5]), false, 'en') + }) + test('default', () => { + expect(generateIfFilterOptionsData('', [testData])).toMatchSnapshot() + }) +}) diff --git a/test/logic/generateFilterdata/__snapshots__/Subform.test.js.snap b/test/logic/generateFilterdata/__snapshots__/Subform.test.js.snap new file mode 100644 index 0000000..70b10e5 --- /dev/null +++ b/test/logic/generateFilterdata/__snapshots__/Subform.test.js.snap @@ -0,0 +1,60 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Generate filter data: Subform > default 1`] = ` +{ + "operators": { + "Text": [ + { + "en_label": "Equal", + "label": "等于", + "style": "noop", + "value": "equal", + }, + { + "en_label": "Not equal", + "label": "不等于", + "style": "noop", + "value": "not_equal", + }, + { + "en_label": "Contains", + "label": "包含", + "style": "tags", + "value": "contains", + }, + { + "en_label": "Not contain", + "label": "不包含", + "style": "tags", + "value": "not_contain", + }, + { + "en_label": "Empty", + "label": "为空", + "style": "none", + "value": "empty", + }, + { + "en_label": "Not empty", + "label": "不为空", + "style": "none", + "value": "not_empty", + }, + ], + }, + "options": [ + { + "includeOperator": { + "operator": [ + "empty", + "not_empty", + ], + }, + "label": "Sub-form", + "operatorKey": "Text", + "renderType": "NONE", + "value": "{{test-id-nanoid}}", + }, + ], +} +`; diff --git a/test/logic/validator/Subform.test.js b/test/logic/validator/Subform.test.js index 33ea604..c8d7478 100644 --- a/test/logic/validator/Subform.test.js +++ b/test/logic/validator/Subform.test.js @@ -6,7 +6,7 @@ import * as erComponentsConfig from '@ER/formEditor/componentsConfig.js' describe('Subform', () => { let field = {} beforeAll(() => { - field = erGeneratorData(_.cloneDeep(erComponentsConfig.fieldsConfig[2].list[5]), true, 'en') + field = erGeneratorData(_.cloneDeep(erComponentsConfig.fieldsConfig[2].list[5]), false, 'en') }) test('empty', () => { expect(