Skip to content

Commit

Permalink
test(subform): generateFilterdata
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberty-liu committed Sep 11, 2023
1 parent 0f661bc commit 69e8ad0
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/logic/generateFilterdata/Subform.test.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
60 changes: 60 additions & 0 deletions test/logic/generateFilterdata/__snapshots__/Subform.test.js.snap
Original file line number Diff line number Diff line change
@@ -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}}",
},
],
}
`;
2 changes: 1 addition & 1 deletion test/logic/validator/Subform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 69e8ad0

Please sign in to comment.