Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[isomorphic-unfetch] Add isomorphic-unfetch_v3 #2908

Merged
merged 3 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

declare module 'isomorphic-unfetch' {
declare module.exports: (input: string | Request | URL, init?: RequestOptions) => Promise<Response>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import isoUnfetch from 'isomorphic-unfetch';

(isoUnfetch('foo'): Promise<Response>);
(isoUnfetch('foo', {}): Promise<Response>);

// $ExpectError url has to be string
(isoUnfetch(123): Promise<any>);

isoUnfetch('foo', {
method: 'GET'
});

isoUnfetch('foo', {
body: 'bar'
});

// $ExpectError number is not a valid body type
isoUnfetch('foo', {
body: 5
});

// Response tests
isoUnfetch('foo').then(res => {
(res.clone(): Response);

// Response Headers
(res.headers: Headers);
(res.headers.append('foo', 'bar'): void);
// $ExpectError
(res.headers.append(5, 'bar'): void);
(res.headers.delete('foo'): void);
// $ExpectError
(res.headers.delete(5): void);
(res.headers.entries(): Iterator<*>);
(res.headers.get('test'): null | string);
// $ExpectError
(res.headers.get(5): null | string);
(res.headers.has('foo'): boolean);
// $ExpectError
(res.headers.has(5): boolean);
(res.headers.keys(): Iterator<string>);
// $ExpectError value should be a string
(res.headers.set('foo', 5): void);
(res.headers.values(): Iterator<*>);

(res.ok: boolean);
(res.status: number);
(res.statusText: string);

// Response type
(res.type: ResponseType);
res.type = 'basic';
// $ExpectError foo is not a valid option
res.type = 'foo';

(res.url: string);
});