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

Commit

Permalink
Modify on Submit test
Browse files Browse the repository at this point in the history
  • Loading branch information
uppal101 committed Oct 16, 2017
1 parent 02e8cd1 commit 30f259a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 7 deletions.
71 changes: 67 additions & 4 deletions packages/api-explorer-ui/__tests__/Doc.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,77 @@ describe('onSubmit', () => {
expect(doc.state('loading')).toBe(true);
});

xtest('should make request on Submit', () => {
const doc = mount(<Doc {...props} />);
test.only('should make request on Submit', () => {
// const req = {
// log: {
// entries: [
// {
// request: {
// headers: [
// {
// name: 'Authorization',
// value: 'Bearer api-key',
// },
// ],
// queryString: [],
// postData: {
// text: '{"category":{},"name":1,"photoUrls":[1]}',
// },
// method: 'POST',
// url: 'http://petstore.swagger.io/v2/pet',
// },
// },
// ],
// },
// };

const props2 = {
doc: {
title: 'Title',
slug: 'slug',
type: 'endpoint',
swagger: { path: '/pet' },
api: { method: 'post' },
formData: {
body: {
category: { id: undefined, name: undefined },
name: '1',
photoUrls: ['1'],
status: undefined,
tags: undefined,
},
},
// requestBody: { type: 'object', properties: { a: { type: 'string' } } },
onSubmit: () => {},
},
oas,
setLanguage: () => {},
};
const doc = mount(<Doc {...props2} />);
doc.instance().onSubmit();
doc.instance().onChange({ auth: { api_key: 'api-key' } });
doc.instance().onSubmit();

expect(doc.state('result')).toBe(false);
expect(doc.state('needsAuth')).toBe(false);
expect(doc.state('result')).toEqual({
init: true,
isBinary: false,
method: 'POST',
requestHeaders: 'Authorization : Bearer api-key',
responseHeaders: 'content-disposition,application/json',
statusCode: [200, 'OK', 'success'],
responseBody: {
id: 9205436248879918000,
category: { id: 0 },
name: '1',
photoUrls: ['1'],
tags: [],
},
url: 'http://petstore.swagger.io/v2/pet',
});
expect(doc.state('loading')).toBe(false);
expect(doc.state('responseTabClass')).toBe(
'hub-reference-right hub-reference-results tabber-parent on',
);
});
});

Expand Down
6 changes: 3 additions & 3 deletions packages/api-explorer-ui/src/CodeSampleResponseTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CodeSampleResponseTabs extends React.Component {

render() {
const { styleClass, result, oas, operation, hideResults } = this.props;
const allSecurities = operation.prepareSecurity();
// const allSecurities = operation.prepareSecurity();

return (
<div className={styleClass}>
Expand Down Expand Up @@ -82,15 +82,15 @@ class CodeSampleResponseTabs extends React.Component {
>
Metadata
</a>
{/* {showCodeResults(oas, operation).length && (
{showCodeResults(oas, operation).length > 0 && (
<a
className="hub-reference-results-back pull-right"
href="#"
onClick={hideResults()}
>
<span className="fa fa-chevron-circle-left"> to examples </span>
</a>
)} */}
)}
</ul>
<div
className="tabber-body tabber-body-result"
Expand Down

0 comments on commit 30f259a

Please sign in to comment.