|
| 1 | +import * as React from 'react'; |
| 2 | +import { shallow } from 'enzyme'; |
| 3 | +import toJson from 'enzyme-to-json'; |
| 4 | + |
| 5 | +import { filterPropsDeep } from '../../../utils/test-utils'; |
| 6 | + |
| 7 | +import { RedocNormalizedOptions } from '../../../services/RedocNormalizedOptions'; |
| 8 | +import { OpenAPIParser, SchemaModel } from '../../../services'; |
| 9 | +import { Schema } from '../Schema'; |
| 10 | +import { OneOfSchema } from '../OneOfSchema'; |
| 11 | + |
| 12 | +const options = new RedocNormalizedOptions({}); |
| 13 | +describe('Components', () => { |
| 14 | + describe('SchemaView', () => { |
| 15 | + describe('OneOf', () => { |
| 16 | + it('should pass down skipReadOnly/skipReadWrite to nested oneOf', () => { |
| 17 | + const parser = new OpenAPIParser( |
| 18 | + { openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} }, |
| 19 | + undefined, |
| 20 | + options, |
| 21 | + ); |
| 22 | + |
| 23 | + const schema = new SchemaModel( |
| 24 | + parser, |
| 25 | + { oneOf: [{ type: 'string' }, { type: 'integer' }] }, |
| 26 | + '', |
| 27 | + options, |
| 28 | + ); |
| 29 | + let schemaViewElement = shallow( |
| 30 | + <Schema schema={schema} skipWriteOnly={true} />, |
| 31 | + ).getElement(); |
| 32 | + expect(schemaViewElement.type).toEqual(OneOfSchema); |
| 33 | + expect(schemaViewElement.props.skipWriteOnly).toBeTruthy(); |
| 34 | + expect(schemaViewElement.props.skipReadOnly).toBeFalsy(); |
| 35 | + |
| 36 | + schemaViewElement = shallow(<Schema schema={schema} skipReadOnly={true} />).getElement(); |
| 37 | + |
| 38 | + expect(schemaViewElement.type).toEqual(OneOfSchema); |
| 39 | + expect(schemaViewElement.props.skipWriteOnly).toBeFalsy(); |
| 40 | + expect(schemaViewElement.props.skipReadOnly).toBeTruthy(); |
| 41 | + }); |
| 42 | + }); |
| 43 | + }); |
| 44 | +}); |
0 commit comments