Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 30f259a

Browse files
committed
Modify on Submit test
1 parent 02e8cd1 commit 30f259a

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

packages/api-explorer-ui/__tests__/Doc.test.jsx

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,77 @@ describe('onSubmit', () => {
8787
expect(doc.state('loading')).toBe(true);
8888
});
8989

90-
xtest('should make request on Submit', () => {
91-
const doc = mount(<Doc {...props} />);
90+
test.only('should make request on Submit', () => {
91+
// const req = {
92+
// log: {
93+
// entries: [
94+
// {
95+
// request: {
96+
// headers: [
97+
// {
98+
// name: 'Authorization',
99+
// value: 'Bearer api-key',
100+
// },
101+
// ],
102+
// queryString: [],
103+
// postData: {
104+
// text: '{"category":{},"name":1,"photoUrls":[1]}',
105+
// },
106+
// method: 'POST',
107+
// url: 'http://petstore.swagger.io/v2/pet',
108+
// },
109+
// },
110+
// ],
111+
// },
112+
// };
113+
114+
const props2 = {
115+
doc: {
116+
title: 'Title',
117+
slug: 'slug',
118+
type: 'endpoint',
119+
swagger: { path: '/pet' },
120+
api: { method: 'post' },
121+
formData: {
122+
body: {
123+
category: { id: undefined, name: undefined },
124+
name: '1',
125+
photoUrls: ['1'],
126+
status: undefined,
127+
tags: undefined,
128+
},
129+
},
130+
// requestBody: { type: 'object', properties: { a: { type: 'string' } } },
131+
onSubmit: () => {},
132+
},
133+
oas,
134+
setLanguage: () => {},
135+
};
136+
const doc = mount(<Doc {...props2} />);
92137
doc.instance().onSubmit();
93138
doc.instance().onChange({ auth: { api_key: 'api-key' } });
94139
doc.instance().onSubmit();
95140

96-
expect(doc.state('result')).toBe(false);
97-
expect(doc.state('needsAuth')).toBe(false);
141+
expect(doc.state('result')).toEqual({
142+
init: true,
143+
isBinary: false,
144+
method: 'POST',
145+
requestHeaders: 'Authorization : Bearer api-key',
146+
responseHeaders: 'content-disposition,application/json',
147+
statusCode: [200, 'OK', 'success'],
148+
responseBody: {
149+
id: 9205436248879918000,
150+
category: { id: 0 },
151+
name: '1',
152+
photoUrls: ['1'],
153+
tags: [],
154+
},
155+
url: 'http://petstore.swagger.io/v2/pet',
156+
});
157+
expect(doc.state('loading')).toBe(false);
158+
expect(doc.state('responseTabClass')).toBe(
159+
'hub-reference-right hub-reference-results tabber-parent on',
160+
);
98161
});
99162
});
100163

packages/api-explorer-ui/src/CodeSampleResponseTabs.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CodeSampleResponseTabs extends React.Component {
2626

2727
render() {
2828
const { styleClass, result, oas, operation, hideResults } = this.props;
29-
const allSecurities = operation.prepareSecurity();
29+
// const allSecurities = operation.prepareSecurity();
3030

3131
return (
3232
<div className={styleClass}>
@@ -82,15 +82,15 @@ class CodeSampleResponseTabs extends React.Component {
8282
>
8383
Metadata
8484
</a>
85-
{/* {showCodeResults(oas, operation).length && (
85+
{showCodeResults(oas, operation).length > 0 && (
8686
<a
8787
className="hub-reference-results-back pull-right"
8888
href="#"
8989
onClick={hideResults()}
9090
>
9191
<span className="fa fa-chevron-circle-left"> to examples </span>
9292
</a>
93-
)} */}
93+
)}
9494
</ul>
9595
<div
9696
className="tabber-body tabber-body-result"

0 commit comments

Comments
 (0)