Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[react-native-url-polyfill] New definition (#4246)
* add initial definition * add some api tests
- Loading branch information
1 parent
d576e7d
commit edaf30f
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...ns/npm/react-native-url-polyfill_v1.x.x/flow_v0.83.x-/react-native-url-polyfill_v1.x.x.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,13 @@ | ||
declare module 'react-native-url-polyfill' { | ||
import typeof { URL as NativeURL, URLSearchParams as NativeURLSearchParams } from 'url'; | ||
|
||
declare export var URL: NativeURL; | ||
|
||
declare export var URLSearchParams: NativeURLSearchParams; | ||
|
||
declare export function setupURLPolyfill(): void; | ||
} | ||
|
||
declare module 'react-native-url-polyfill/auto' { | ||
declare module.exports: void; | ||
} |
29 changes: 29 additions & 0 deletions
29
...m/react-native-url-polyfill_v1.x.x/flow_v0.83.x-/test_react-native-url-polyfill_v1.x.x.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,29 @@ | ||
// @flow | ||
import { describe, it } from 'flow-typed-test'; | ||
import { setupURLPolyfill, URL, URLSearchParams } from 'react-native-url-polyfill'; | ||
import auto from 'react-native-url-polyfill/auto'; | ||
|
||
describe('react-native-url-polyfill', () => { | ||
it('simple usage', () => { | ||
// It's an auto running script | ||
(auto: void); | ||
}); | ||
|
||
it('flexible usage', () => { | ||
setupURLPolyfill(); | ||
|
||
// $FlowExpectedError[extra-arg] takes no args | ||
setupURLPolyfill('test'); | ||
}); | ||
|
||
it('convenient usage', () => { | ||
const url = new URL('https://github.com'); | ||
const searchParams = new URLSearchParams('q=GitHub'); | ||
|
||
// Has the same methods as node `url` | ||
// $FlowExpectedError[extra-arg] | ||
url.toJSON('test'); | ||
// $FlowExpectedError[incompatible-call] | ||
searchParams.delete(); | ||
}); | ||
}); |