-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: skipReadOnly/skipWritOnly not passing down to nested OneOf
- Loading branch information
1 parent
02c2413
commit 2462639
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import toJson from 'enzyme-to-json'; | ||
|
||
import { filterPropsDeep } from '../../../utils/test-utils'; | ||
|
||
import { RedocNormalizedOptions } from '../../../services/RedocNormalizedOptions'; | ||
import { OpenAPIParser, SchemaModel } from '../../../services'; | ||
import { Schema } from '../Schema'; | ||
import { OneOfSchema } from '../OneOfSchema'; | ||
|
||
const options = new RedocNormalizedOptions({}); | ||
describe('Components', () => { | ||
describe('SchemaView', () => { | ||
describe('OneOf', () => { | ||
it('should pass down skipReadOnly/skipReadWrite to nested oneOf', () => { | ||
const parser = new OpenAPIParser( | ||
{ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} }, | ||
undefined, | ||
options, | ||
); | ||
|
||
const schema = new SchemaModel( | ||
parser, | ||
{ oneOf: [{ type: 'string' }, { type: 'integer' }] }, | ||
'', | ||
options, | ||
); | ||
let schemaViewElement = shallow( | ||
<Schema schema={schema} skipWriteOnly={true} />, | ||
).getElement(); | ||
expect(schemaViewElement.type).toEqual(OneOfSchema); | ||
expect(schemaViewElement.props.skipWriteOnly).toBeTruthy(); | ||
expect(schemaViewElement.props.skipReadOnly).toBeFalsy(); | ||
|
||
schemaViewElement = shallow(<Schema schema={schema} skipReadOnly={true} />).getElement(); | ||
|
||
expect(schemaViewElement.type).toEqual(OneOfSchema); | ||
expect(schemaViewElement.props.skipWriteOnly).toBeFalsy(); | ||
expect(schemaViewElement.props.skipReadOnly).toBeTruthy(); | ||
}); | ||
}); | ||
}); | ||
}); |