-
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.
chore: add tests for cover field default crash (#2389)
- Loading branch information
1 parent
c86fd7f
commit 2eff85a
Showing
8 changed files
with
129 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { FieldDetails } from '../Fields/FieldDetails'; | ||
import { SchemaModel } from '../../services/models/Schema'; | ||
import { withTheme } from '../testProviders'; | ||
|
||
jest.mock('../ExternalDocumentation/ExternalDocumentation', () => ({ | ||
ExternalDocumentation: () => { | ||
return <div />; | ||
}, | ||
})); | ||
|
||
describe('FieldDetailsComponent', () => { | ||
it('renders correctly', () => { | ||
const mockFieldProps = { | ||
showExamples: true, | ||
field: { | ||
schema: { | ||
type: 'array', | ||
default: [], | ||
typePrefix: 'test type prefix', | ||
displayType: 'array', | ||
title: 'test title', | ||
externalDocs: undefined, | ||
constraints: [''], | ||
} as SchemaModel, | ||
example: 'example', | ||
name: 'name', | ||
expanded: false, | ||
required: false, | ||
kind: '', | ||
deprecated: false, | ||
collapse: jest.fn(), | ||
toggle: jest.fn(), | ||
explode: false, | ||
expand: jest.fn(), | ||
description: 'test description', | ||
}, | ||
renderDiscriminatorSwitch: jest.fn(), | ||
}; | ||
|
||
const wrapper = shallow(withTheme(<FieldDetails {...mockFieldProps} />)); | ||
|
||
expect(wrapper.render()).toMatchSnapshot(); | ||
}); | ||
}); |
69 changes: 69 additions & 0 deletions
69
src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap
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,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`FieldDetailsComponent renders correctly 1`] = ` | ||
<div> | ||
<div> | ||
<span | ||
class="sc-kpDqfm sc-dAlyuH cGRfjn gHomYR" | ||
> | ||
test type prefix | ||
</span> | ||
<span | ||
class="sc-kpDqfm sc-jlZhew cGRfjn dYtiIA" | ||
> | ||
array | ||
</span> | ||
<span | ||
class="sc-kpDqfm sc-cwHptR cGRfjn gyVIPr" | ||
> | ||
(test title) | ||
</span> | ||
<span> | ||
<span | ||
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH" | ||
> | ||
</span> | ||
</span> | ||
</div> | ||
<div> | ||
<span | ||
class="sc-kpDqfm cGRfjn" | ||
> | ||
Default: | ||
</span> | ||
<span | ||
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn" | ||
> | ||
"" | ||
</span> | ||
</div> | ||
<div> | ||
<span | ||
class="sc-kpDqfm cGRfjn" | ||
> | ||
Example: | ||
</span> | ||
<span | ||
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn" | ||
> | ||
"example" | ||
</span> | ||
</div> | ||
<div> | ||
<div | ||
class="sc-lcIPJg sc-hknOHE gBHqkN eigFbs" | ||
> | ||
<p> | ||
test description | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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