Skip to content

Commit

Permalink
Unit coverage and approval tests fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
mahamdan committed Oct 30, 2023
1 parent 3de9e58 commit 384a6d9
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 72 deletions.
11 changes: 9 additions & 2 deletions src/components/JsonViewer/JsonViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,22 @@ class Json extends React.PureComponent<JsonProps> {
}

render() {
const { data } = this.props;
const showFoldingButtons =
data && Object.values(data).some(value => typeof value === 'object' && value !== null);
return (
<CopyButtonWrapper data={this.props.data.content || this.props.data}>
{({ renderCopyButton }) => (
<JsonViewerWrap>
{!this.props.hideButtons && !this.props.error && (
<SampleControls>
{renderCopyButton()}
{<button onClick={this.expandAll}> Expand all </button>}
{<button onClick={this.collapseAll}> Collapse all </button>}
{showFoldingButtons && (
<>
<button onClick={this.expandAll}> Expand all </button>
<button onClick={this.collapseAll}> Collapse all </button>
</>
)}
</SampleControls>
)}
<>
Expand Down
3 changes: 2 additions & 1 deletion src/components/SchemaDefinition/SchemaDefinition.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';

import { RightPanel, MiddlePanel, MimeLabel, Row, Section } from '../../common-elements';
import { MediaTypeModel, OpenAPIParser, RedocNormalizedOptions } from '../../services';
import { OpenAPIParser, RedocNormalizedOptions } from '../../services';
import { MediaTypeModel } from '../../services/models';
import styled from '../../styled-components';
import { OpenAPIMediaType } from '../../types';
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
Expand Down
3 changes: 2 additions & 1 deletion src/components/__tests__/Schema.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';

import { Schema } from '../';
import { OpenAPIParser, SchemaModel } from '../../services';
import { OpenAPIParser } from '../../services';
import { SchemaModel } from '../../services/models';
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
import { withTheme } from '../testProviders';

Expand Down

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,59 @@ exports[`FieldDetailsComponent renders correctly 1`] = `
<div>
<div>
<span
class="sc-kpDqfm sc-dAlyuH cGRfjn gHomYR"
class="sc-kpDqfm sc-dAlyuH hQmucp iJUbAB"
>
test type prefix
</span>
<span
class="sc-kpDqfm sc-jlZhew cGRfjn dYtiIA"
class="sc-kpDqfm sc-jlZhew hQmucp dKmyvV"
>
array
</span>
<span
class="sc-kpDqfm sc-cwHptR cGRfjn gyVIPr"
class="sc-kpDqfm sc-cwHptR hQmucp dlJmJy"
>
(test title)
</span>
<span>
<span
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
class="sc-kpDqfm sc-gFqAkR hQmucp kxZcxR"
>
</span>
</span>
</div>
<div>
<span
class="sc-kpDqfm cGRfjn"
class="sc-kpDqfm hQmucp"
>
Default:
</span>
<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn"
class="sc-kpDqfm sc-eldPxv hQmucp eivFDv"
>
[]
</span>
</div>
<div>
<span
class="sc-kpDqfm cGRfjn"
class="sc-kpDqfm hQmucp"
>
Example:
</span>
<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn"
class="sc-kpDqfm sc-eldPxv hQmucp eivFDv"
>
"example"
</span>
</div>
<div>
<div
class="sc-lcIPJg sc-hknOHE gBHqkN jFBMaE"
class="sc-fhzFiK sc-bbSZdi kQJSMe gNfGjX"
>
<p>
test description
Expand All @@ -72,57 +72,57 @@ exports[`FieldDetailsComponent renders correctly when default value is object in
<div>
<div>
<span
class="sc-kpDqfm sc-dAlyuH cGRfjn gHomYR"
class="sc-kpDqfm sc-dAlyuH hQmucp iJUbAB"
/>
<span
class="sc-kpDqfm sc-jlZhew cGRfjn dYtiIA"
class="sc-kpDqfm sc-jlZhew hQmucp dKmyvV"
>
object
</span>
<span
class="sc-kpDqfm sc-cwHptR cGRfjn gyVIPr"
class="sc-kpDqfm sc-cwHptR hQmucp dlJmJy"
>
(test title)
</span>
<span>
<span
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
class="sc-kpDqfm sc-gFqAkR hQmucp kxZcxR"
>
</span>
</span>
</div>
<div>
<span
class="sc-kpDqfm cGRfjn"
class="sc-kpDqfm hQmucp"
>
Default:
</span>
<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn"
class="sc-kpDqfm sc-eldPxv hQmucp eivFDv"
>
{"properties":{}}
</span>
</div>
<div>
<span
class="sc-kpDqfm cGRfjn"
class="sc-kpDqfm hQmucp"
>
Example:
</span>
<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn"
class="sc-kpDqfm sc-eldPxv hQmucp eivFDv"
>
"example"
</span>
</div>
<div>
<div
class="sc-lcIPJg sc-hknOHE gBHqkN jFBMaE"
class="sc-fhzFiK sc-bbSZdi kQJSMe gNfGjX"
>
<p>
test description
Expand All @@ -138,32 +138,32 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty
<div>
<div>
<span
class="sc-kpDqfm sc-dAlyuH cGRfjn gHomYR"
class="sc-kpDqfm sc-dAlyuH hQmucp iJUbAB"
/>
<span
class="sc-kpDqfm sc-jlZhew cGRfjn dYtiIA"
class="sc-kpDqfm sc-jlZhew hQmucp dKmyvV"
>
Array of strings
</span>
<span
class="sc-kpDqfm sc-cwHptR cGRfjn gyVIPr"
class="sc-kpDqfm sc-cwHptR hQmucp dlJmJy"
>
(test title)
</span>
<span>
<span
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
class="sc-kpDqfm sc-gFqAkR hQmucp kxZcxR"
>
</span>
</span>
<span
class="sc-kpDqfm sc-dAlyuH sc-dxcDKg cGRfjn gHomYR gXntsr"
class="sc-kpDqfm sc-dAlyuH sc-dNsVcS hQmucp iJUbAB hXHncj"
>
[
<span
class="sc-kpDqfm sc-eDPEul cGRfjn erJHow"
class="sc-kpDqfm sc-eDPEul hQmucp drwcsG"
>
^see regex[0-9]$
</span>
Expand All @@ -173,20 +173,20 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty
<div>
<span
class="sc-kpDqfm cGRfjn"
class="sc-kpDqfm hQmucp"
>
Example:
</span>
<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn"
class="sc-kpDqfm sc-eldPxv hQmucp eivFDv"
>
"example"
</span>
</div>
<div>
<div
class="sc-lcIPJg sc-hknOHE gBHqkN jFBMaE"
class="sc-fhzFiK sc-bbSZdi kQJSMe gNfGjX"
>
<p>
test description
Expand Down
16 changes: 8 additions & 8 deletions src/components/__tests__/__snapshots__/OneOfSchema.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
exports[`Components SchemaView OneOf deprecated should match snapshot 1`] = `
<div>
<span
class="sc-fUnMCh hPwMmL"
class="sc-gFqAkR kuMzrK"
>
One of
</span>
<div
class="sc-feUZmu bTropM"
class="sc-fPXMVe itTKpk"
>
<button
class="sc-hzhJZQ ilKqWS"
class="sc-ikkxIA kuVwkF"
>
string
</button>
<button
class="sc-hzhJZQ emRRrf"
class="sc-ikkxIA cEqWki"
>
integer
</button>
</div>
<div>
<span
class="sc-jEACwC gWyYnj"
class="sc-kpDqfm cliRNV"
type="warning"
>
Deprecated
Expand All @@ -33,18 +33,18 @@ exports[`Components SchemaView OneOf deprecated should match snapshot 1`] = `
<div>
<div>
<span
class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"
class="sc-hknOHE sc-uVWWZ lgOCmT kSEYXZ"
/>
<span
class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr"
class="sc-hknOHE sc-hCPjZK lgOCmT gRpOTr"
>
string
</span>
</div>
<div>
<div
class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"
class="sc-fHjqPf sc-kOHTFB izoHQx imYYjj"
/>
</div>
</div>
Expand Down
Loading

0 comments on commit 384a6d9

Please sign in to comment.