From 3eaa3ca1b522df11c42c2ac647c3568df8256461 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sun, 16 Jul 2023 23:38:31 +0300 Subject: [PATCH] fixed .send binding tests --- plugins/jsvm/binds_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/jsvm/binds_test.go b/plugins/jsvm/binds_test.go index af8a147b..38ae9001 100644 --- a/plugins/jsvm/binds_test.go +++ b/plugins/jsvm/binds_test.go @@ -923,16 +923,6 @@ func TestHttpClientBindsSend(t *testing.T) { return result; } - let testErr; - try { - $http.send({ url: testUrl + "?testError=1" }) - } catch (err) { - testErr = err - } - if (!testErr) { - throw new Error("Expected an error") - } - let testTimeout; try { $http.send({ @@ -946,34 +936,44 @@ func TestHttpClientBindsSend(t *testing.T) { throw new Error("Expected timeout error") } + // error response check + const test0 = $http.send({ + url: testUrl + "?testError=1", + }) + // basic fields check const test1 = $http.send({ method: "post", url: testUrl, data: {"data": "example"}, - headers: {"header1": "123", "header2": "456"} + headers: {"header1": "123", "header2": "456"}, }) // with custom content-type header const test2 = $http.send({ url: testUrl, - headers: {"content-type": "text/plain"} + headers: {"content-type": "text/plain"}, }) const scenarios = [ + [test0, { + "statusCode": "400", + }], [test1, { + "statusCode": "200", "json.method": "POST", "json.headers.header1": "123", "json.headers.header2": "456", "json.headers.content_type": "application/json", // default }], [test2, { + "statusCode": "200", "json.method": "GET", "json.headers.content_type": "text/plain", }], ] - for (let scenario in scenarios) { + for (let scenario of scenarios) { const result = scenario[0]; const expectations = scenario[1];