-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fromOpenApi): remove extra whitespace from content type (#62)
Co-authored-by: Kiskae <Kiskae@users.noreply.github.com> Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
- Loading branch information
1 parent
adaa00f
commit 02157b5
Showing
4 changed files
with
82 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { getAcceptedContentTypes } from './open-api-utils.js' | ||
|
||
it('returns a single content type as-is', () => { | ||
expect( | ||
getAcceptedContentTypes(new Headers([['accept', 'text/html']])), | ||
).toEqual(['text/html']) | ||
}) | ||
|
||
it('ignores whitespace separating multiple content types', () => { | ||
expect( | ||
getAcceptedContentTypes( | ||
new Headers([['accept', 'text/html, application/xhtml+xml, */*']]), | ||
), | ||
).toEqual(['text/html', 'application/xhtml+xml', '*/*']) | ||
}) | ||
|
||
it('removes an empty content type', () => { | ||
expect(getAcceptedContentTypes(new Headers([['accept', ', ,']]))).toEqual([]) | ||
|
||
expect( | ||
getAcceptedContentTypes(new Headers([['accept', 'text/html, , */*']])), | ||
).toEqual(['text/html', '*/*']) | ||
}) | ||
|
||
describe.skip('complex "accept" headers', () => { | ||
it('supports weight reordering', () => { | ||
expect( | ||
getAcceptedContentTypes( | ||
new Headers([ | ||
[ | ||
'accept', | ||
'text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c', | ||
], | ||
]), | ||
), | ||
).toEqual(['text/html', 'text/x-c', 'text/x-dvi', 'text/plain']) | ||
}) | ||
|
||
it('supports specificity reordering', () => { | ||
expect( | ||
getAcceptedContentTypes( | ||
new Headers([ | ||
['accept', 'text/*, text/plain, text/plain;format=flowed, */*'], | ||
]), | ||
), | ||
).toEqual(['text/plain;format=flowed', 'text/plain', 'text/*', '*/*']) | ||
}) | ||
}) |
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
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
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