forked from temando/open-api-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request temando#73 from brendo/issue-36-handle-mixed-data-…
…type Support 'type' being an array. Closes temando#36
- Loading branch information
Showing
16 changed files
with
683 additions
and
8,427 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
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
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,62 @@ | ||
import React from 'react'; | ||
import Property from './../../src/components/Property/Property'; | ||
import renderer from 'react-test-renderer'; | ||
import ReactShallowRenderer from 'react-test-renderer/shallow'; | ||
|
||
describe('<Property />', () => { | ||
it('can render a basic property', () => { | ||
const tree = renderer.create( | ||
<Property name={'type'} type={['string']} isRequired isLast /> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it('can render a property with enum', () => { | ||
const tree = renderer.create( | ||
<Property | ||
name={'packagingType'} | ||
type={['string']} | ||
enumValues={['box', 'carton']} | ||
isRequired /> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it('can render a property with a subtype', () => { | ||
const tree = renderer.create( | ||
<Property | ||
name={'data'} | ||
type={['array']} | ||
subtype={'object'} | ||
isRequired={false} /> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it('can render a property with description', () => { | ||
const shallow = new ReactShallowRenderer(); | ||
const tree = shallow.render( | ||
<Property | ||
name={'type'} | ||
type={['string']} | ||
description={'This is _markdown_ text'} | ||
isRequired /> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
it('can render a property with multiple types', () => { | ||
const tree = renderer.create( | ||
<Property | ||
name={'value'} | ||
type={['string', 'number']} | ||
isRequired={false} /> | ||
); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
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,148 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Property /> can render a basic property 1`] = ` | ||
<tr | ||
className="property last" | ||
onClick={undefined} | ||
> | ||
<td | ||
className="property-name" | ||
> | ||
<span> | ||
type | ||
</span> | ||
</td> | ||
<td | ||
className="property-info" | ||
> | ||
<span> | ||
string | ||
</span> | ||
<span | ||
className="property-required" | ||
> | ||
Required | ||
</span> | ||
</td> | ||
</tr> | ||
`; | ||
|
||
exports[`<Property /> can render a property with a subtype 1`] = ` | ||
<tr | ||
className="property" | ||
onClick={undefined} | ||
> | ||
<td | ||
className="property-name" | ||
> | ||
<span> | ||
data | ||
</span> | ||
</td> | ||
<td | ||
className="property-info" | ||
> | ||
<span> | ||
array | ||
</span> | ||
<span> | ||
of | ||
object | ||
</span> | ||
</td> | ||
</tr> | ||
`; | ||
|
||
exports[`<Property /> can render a property with description 1`] = ` | ||
<tr | ||
className="property" | ||
onClick={undefined} | ||
> | ||
<td | ||
className="property-name" | ||
> | ||
<span> | ||
type | ||
</span> | ||
</td> | ||
<td | ||
className="property-info" | ||
> | ||
<span> | ||
string | ||
</span> | ||
<span | ||
className="property-required" | ||
> | ||
Required | ||
</span> | ||
<Description | ||
description="This is _markdown_ text" | ||
/> | ||
</td> | ||
</tr> | ||
`; | ||
|
||
exports[`<Property /> can render a property with enum 1`] = ` | ||
<tr | ||
className="property" | ||
onClick={undefined} | ||
> | ||
<td | ||
className="property-name" | ||
> | ||
<span> | ||
packagingType | ||
</span> | ||
</td> | ||
<td | ||
className="property-info" | ||
> | ||
<span> | ||
string | ||
</span> | ||
<span | ||
className="property-required" | ||
> | ||
Required | ||
</span> | ||
<div> | ||
<span> | ||
Valid values: | ||
</span> | ||
<span | ||
className="enum" | ||
> | ||
box | ||
</span> | ||
<span | ||
className="enum" | ||
> | ||
carton | ||
</span> | ||
</div> | ||
</td> | ||
</tr> | ||
`; | ||
|
||
exports[`<Property /> can render a property with multiple types 1`] = ` | ||
<tr | ||
className="property" | ||
onClick={undefined} | ||
> | ||
<td | ||
className="property-name" | ||
> | ||
<span> | ||
value | ||
</span> | ||
</td> | ||
<td | ||
className="property-info" | ||
> | ||
<span> | ||
string, number | ||
</span> | ||
</td> | ||
</tr> | ||
`; |
Oops, something went wrong.