Skip to content

Commit

Permalink
fix(json-schema): fix editable valid (#1679)
Browse files Browse the repository at this point in the history
* fix(json-schema): fix editable valid

* test(json-schema): add transform field props test
  • Loading branch information
febugcoder authored Jun 29, 2021
1 parent 97577b5 commit dbb2258
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions packages/json-schema/src/__tests__/transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ test('transform field props', () => {
type: 'string',
})
expect(schema.toFieldProps()).not.toBeUndefined()
const schema2 = new Schema({
type: 'object',
properties: {
writeOnly: {
type: 'string',
writeOnly: true,
},
'x-editable': {
type: 'string',
'x-editable': true,
},
readOnly: {
type: 'string',
readOnly: true,
},
'x-read-only': {
type: 'string',
'x-read-only': true,
},
'x-read-pretty': {
type: 'string',
'x-read-pretty': true,
},
},
})
expect(schema2.properties['writeOnly'].toFieldProps().editable).toBeTruthy()
expect(schema2.properties['x-editable'].toFieldProps().editable).toBeTruthy()
expect(schema2.properties['readOnly'].toFieldProps().readOnly).toBeTruthy()
expect(schema2.properties['x-read-only'].toFieldProps().readOnly).toBeTruthy()
expect(
schema2.properties['x-read-pretty'].toFieldProps().readPretty
).toBeTruthy()
})

test('transform required', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/json-schema/src/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const getBaseProps = (
props.dataSource = dataSource
}

if (!isValid(editable)) {
if (isValid(editable)) {
props.editable = editable
}

Expand Down

0 comments on commit dbb2258

Please sign in to comment.