forked from readmeio/api-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first pass at code samples rendering https://github.com/readmeio/…
…api-explorer/issues/1 Still missing highlighting and values
- Loading branch information
Dom Harrington
committed
Aug 10, 2017
1 parent
87eecf0
commit f770940
Showing
10 changed files
with
313 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"extends": "airbnb", | ||
"rules": { | ||
|
||
"arrow-body-style": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/api-explorer-ui/__tests__/lib/generate-code-snippets.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const generateCodeSnippets = require('../../src/lib/generate-code-snippets'); | ||
|
||
test('should generate a HTML snippet for each lang', () => { | ||
const languages = ['node', 'curl']; | ||
|
||
const snippets = generateCodeSnippets({ | ||
servers: [ | ||
{ url: 'http://example.com' }, | ||
], | ||
}, '/path', 'get', languages); | ||
|
||
expect(Object.keys(snippets)).toEqual(languages); | ||
|
||
Object.keys(snippets).forEach((lang) => { | ||
expect(typeof snippets[lang]).toBe('string'); | ||
// expect(snippets[lang]).toEqual(expect.stringMatching(/cm-s-tomorrow-night/)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const oasToHar = require('../../src/lib/oas-to-har'); | ||
|
||
test('should output a har format', () => { | ||
expect(oasToHar({})).toEqual({ | ||
headers: [], | ||
queryString: [], | ||
postData: {}, | ||
method: '', | ||
url: '', | ||
}); | ||
}); | ||
|
||
test('should uppercase the method', () => { | ||
expect(oasToHar({}, '/', 'get').method).toBe('GET'); | ||
}); | ||
|
||
describe('url', () => { | ||
test('should default to ""', () => { | ||
expect(oasToHar({}, '', '').url).toBe(''); | ||
expect(oasToHar({}, '/path', '').url).toBe('/path'); | ||
}); | ||
|
||
test('should be constructed from servers[0]', () => { | ||
expect(oasToHar({ | ||
servers: [{ url: 'http://example.com' }], | ||
}, '/path', '').url).toBe('http://example.com/path'); | ||
}); | ||
|
||
it('should replace whitespace with %20', () => { | ||
expect(oasToHar({ | ||
servers: [{ url: 'http://example.com' }], | ||
}, '/path with spaces', '').url).toBe('http://example.com/path%20with%20spaces'); | ||
}); | ||
|
||
it('should replace path params with values'); | ||
}); | ||
|
Oops, something went wrong.