From e628172bc5d322666e6f0837ba1adf7849bb6594 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 12 Jun 2018 12:34:24 -0700 Subject: [PATCH] add tests for SuperAgent request --- types/superagent/superagent-tests.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index 66046759f1..46766f8d9e 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -390,3 +390,18 @@ request .then(response => { // reads 404 page as a successful response }); + +// Test that the "Plugin" type from "use" provides a SuperAgentRequest rather than a Request, +// which has additional properties. +const echoPlugin = (request: request.SuperAgentRequest) => { + req.url = '' + req.url; + req.cookies = '' + req.cookies; + if (req.method) { + req.url = '/echo' + } +}; + +request + .get('/echo') + .use(echoPlugin) + .end(); \ No newline at end of file