mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #31982 from ikokostya/got-improve-before-request-hook-test
[got] Improve beforRequest hook test
This commit is contained in:
+14
-1
@@ -287,7 +287,6 @@ got('http://todomvc.com', {
|
||||
});
|
||||
|
||||
got('http://todomvc.com', { throwHttpErrors: false });
|
||||
got('http://todomvc.com', { hooks: { beforeRequest: [ () => 'foo']} });
|
||||
|
||||
// Test timeout options.
|
||||
got('http://todomvc.com', {timeout: 1});
|
||||
@@ -307,6 +306,15 @@ got('http://todomvc.com', {
|
||||
got('http://todomvc.com', {timeout: 1}).catch((err) => err instanceof got.TimeoutError);
|
||||
|
||||
// Test hooks.
|
||||
got('example.com', {
|
||||
hooks: {
|
||||
beforeRequest: [
|
||||
options => {
|
||||
options.headers!['x-foo'] = 'bar';
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
got('example.com', {
|
||||
hooks: {
|
||||
beforeRedirect: [
|
||||
@@ -358,6 +366,11 @@ got('example.com', {
|
||||
|
||||
got('example.com', {
|
||||
hooks: {
|
||||
beforeRequest: [
|
||||
async () => {
|
||||
await doSomethingAsync();
|
||||
}
|
||||
],
|
||||
beforeRedirect: [
|
||||
async () => {
|
||||
await doSomethingAsync();
|
||||
|
||||
Reference in New Issue
Block a user