File tree Expand file tree Collapse file tree 2 files changed +55
-1
lines changed Expand file tree Collapse file tree 2 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,9 @@ export default class OperationTag extends React.Component {
60
60
let tagExternalDocsUrl
61
61
if ( isFunc ( oas3Selectors ) && isFunc ( oas3Selectors . selectedServer ) ) {
62
62
tagExternalDocsUrl = buildUrl ( rawTagExternalDocsUrl , specUrl , { selectedServer : oas3Selectors . selectedServer ( ) } )
63
- }
63
+ } else {
64
+ tagExternalDocsUrl = rawTagExternalDocsUrl
65
+ }
64
66
65
67
let isShownKey = [ "operations-tag" , tag ]
66
68
let showTag = layoutSelectors . isShown ( isShownKey , docExpansion === "full" || docExpansion === "list" )
Original file line number Diff line number Diff line change
1
+ import React from "react"
2
+ import { shallow } from "enzyme"
3
+ import OperationTag from "components/operation-tag"
4
+ import Im from "immutable"
5
+ import { Link } from "components/layout-utils"
6
+
7
+ describe ( "<OperationTag/>" , function ( ) {
8
+ it ( "render externalDocs URL for swagger v2" , function ( ) {
9
+
10
+ const dummyComponent = ( ) => null
11
+ const components = {
12
+ Collapse : ( ) => dummyComponent ,
13
+ Markdown : ( ) => dummyComponent ,
14
+ DeepLink : ( ) => dummyComponent ,
15
+ Link
16
+ }
17
+
18
+ let props = {
19
+ tagObj : Im . fromJS ( {
20
+ tagDetails : {
21
+ externalDocs : {
22
+ description : "Find out more" ,
23
+ url : "http://swagger.io"
24
+ }
25
+ }
26
+ } ) ,
27
+ tag : "testtag" ,
28
+ getConfigs : ( ) => ( { } ) ,
29
+ getComponent : c => components [ c ] ,
30
+ layoutSelectors : {
31
+ currentFilter ( ) {
32
+ return null
33
+ } ,
34
+ isShown ( ) {
35
+ return true
36
+ } ,
37
+ show ( ) {
38
+ return true
39
+ }
40
+ }
41
+ }
42
+
43
+ let wrapper = shallow ( < OperationTag { ...props } /> )
44
+
45
+ const opblockTag = wrapper . find ( ".opblock-tag" )
46
+ expect ( opblockTag . length ) . toEqual ( 1 )
47
+
48
+ const renderedLink = wrapper . find ( "Link" )
49
+ expect ( renderedLink . length ) . toEqual ( 1 )
50
+ expect ( renderedLink . props ( ) . href ) . toEqual ( "http://swagger.io" )
51
+ } )
52
+ } )
You can’t perform that action at this time.
0 commit comments