From cd98b442e17da94a39fc682441fef89cb5f730f8 Mon Sep 17 00:00:00 2001 From: ikokostya Date: Tue, 8 Jan 2019 23:30:06 +0300 Subject: [PATCH] [got] Improve beforRequest hook test Move test case for beforeRequest hook to tests for other hooks. Refs #31769 --- types/got/got-tests.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index d80d0aadcf..c32c7da121 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -268,7 +268,6 @@ got('http://todomvc.com', { cookieJar: new tough.CookieJar() }); got('http://todomvc.com', { retry: 2 }); got('http://todomvc.com', { retry: { retries: 2, methods: ['GET'], statusCodes: [408, 504], maxRetryAfter: 1 } }); got('http://todomvc.com', { throwHttpErrors: false }); -got('http://todomvc.com', { hooks: { beforeRequest: [ () => 'foo']} }); // Test timeout options. got('http://todomvc.com', {timeout: 1}); @@ -288,6 +287,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: [ @@ -339,6 +347,11 @@ got('example.com', { got('example.com', { hooks: { + beforeRequest: [ + async () => { + await doSomethingAsync(); + } + ], beforeRedirect: [ async () => { await doSomethingAsync();