-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59f2ef4
commit f17e992
Showing
5 changed files
with
110 additions
and
35 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,34 @@ | ||
import { _HTTPBuildQuery, _isUrlMatchingRegex } from '../request-utils' | ||
|
||
describe('request utils', () => { | ||
describe('_HTTPBuildQuery', () => { | ||
test.each([ | ||
['builds query string', { x: 'y', a: 'b' }, 'x=y&a=b'], | ||
['skips undefined values', { x: 'y', a: undefined }, 'x=y'], | ||
['skips undefined keys', { x: 'y', a: 'b', undefined: 'c' }, 'x=y&a=b'], | ||
])('%s', (_name, formData, expected) => { | ||
expect(_HTTPBuildQuery(formData)).toEqual(expected) | ||
}) | ||
}) | ||
describe('_isUrlMatchingRegex', () => { | ||
test.each([ | ||
['match query params', 'https://example.com?name=something', '(\\?|\\&)(name.*)\\=([^&]+)', true], | ||
[ | ||
'match query params with trailing slash', | ||
'https://example.com/?name=something', | ||
'(\\?|\\&)(name.*)\\=([^&]+)', | ||
true, | ||
], | ||
['match subdomain wildcard', 'https://app.example.com', '(.*.)?example.com', true], | ||
['match route wildcard', 'https://example.com/something/test', 'example.com/(.*.)/test', true], | ||
['match domain', 'https://example.com', 'example.com', true], | ||
['match domain with protocol', 'https://example.com', 'https://example.com', true], | ||
['match domain with protocol and wildcard', 'https://example.com', 'https://(.*.)?example.com', true], | ||
['does not match query params', 'https://example.com', '(\\?|\\&)(name.*)\\=([^&]+)', false], | ||
['does not match route', 'https://example.com', 'example.com/test', false], | ||
['does not match domain', 'https://example.com', 'anotherone.com', false], | ||
])('%s', (_name, url, regex, expected) => { | ||
expect(_isUrlMatchingRegex(url, regex)).toEqual(expected) | ||
}) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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