Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch(#5672): code highlight styles are now only applied to pre blocks that have the class pre.microlight #5673

Merged
merged 6 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/components/live-response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Headers = ( { headers } )=>{
return (
<div>
<h5>Response headers</h5>
<pre>{headers}</pre>
<pre className="microlight">{headers}</pre>
</div>)
}
Headers.propTypes = {
Expand All @@ -18,7 +18,7 @@ const Duration = ( { duration } ) => {
return (
<div>
<h5>Request duration</h5>
<pre>{duration} ms</pre>
<pre className="microlight">{duration} ms</pre>
</div>
)
}
Expand Down Expand Up @@ -75,7 +75,7 @@ export default class LiveResponse extends React.Component {
{ url && <div>
<h4>Request URL</h4>
<div className="request-url">
<pre>{url}</pre>
<pre className="microlight">{url}</pre>
</div>
</div>
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/components/response-body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class ResponseBody extends React.PureComponent {
bodyEl = <div><a href={ href } download={ download }>{ "Download file" }</a></div>
}
} else {
bodyEl = <pre>Download headers detected but your browser does not support downloading binary via XHR (Blob).</pre>
bodyEl = <pre className="microlight">Download headers detected but your browser does not support downloading binary via XHR (Blob).</pre>
}

// Anything else (CORS)
Expand Down Expand Up @@ -123,7 +123,7 @@ export default class ResponseBody extends React.PureComponent {

// Audio
} else if (/^audio\//i.test(contentType)) {
bodyEl = <pre><audio controls><source src={ url } type={ contentType } /></audio></pre>
bodyEl = <pre className="microlight"><audio controls><source src={ url } type={ contentType } /></audio></pre>
} else if (typeof content === "string") {
bodyEl = <HighlightCode downloadable fileName={`${downloadName}.txt`} value={ content } />
} else if ( content.size > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/style/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@
}
}

.opblock-body pre
.opblock-body pre.microlight
{
font-size: 12px;

Expand Down
19 changes: 17 additions & 2 deletions test/mocha/components/live-response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ describe("<LiveResponse/>", function(){
let response = fromJSOrdered({
status: 200,
url: "http://petstore.swagger.io/v2/pet/1",
headers: {},
headers: {
"content-type": "application/xml"
},
text: "<response/>",
duration: 50
})

let mutatedRequestForSpy = createSpy().andReturn(mutatedRequest)
Expand Down Expand Up @@ -81,8 +84,20 @@ describe("<LiveResponse/>", function(){
expect(curl.props().request).toBe(requests[test.expected.request])

const expectedUrl = requests[test.expected.request].get("url")
expect(wrapper.find("div.request-url pre").text()).toEqual(expectedUrl)
expect(wrapper.find("div.request-url pre.microlight").text()).toEqual(expectedUrl)

let duration = wrapper.find("Duration")
expect(duration.length).toEqual(1)
expect(duration.props().duration).toEqual(50)
expect(duration.html())
.toEqual("<div><h5>Request duration</h5><pre class=\"microlight\">50 ms</pre></div>")

let responseHeaders = wrapper.find("Headers")
expect(duration.length).toEqual(1)
expect(responseHeaders.props().headers.length).toEqual(1)
expect(responseHeaders.props().headers[0].key).toEqual("content-type")
expect(responseHeaders.html())
.toEqual("<div><h5>Response headers</h5><pre class=\"microlight\"><span class=\"headerline\"> content-type: application/xml </span></pre></div>")
})
})
})