From e8c74f76b4ca9523927571ffa2071bc9dd35c71e Mon Sep 17 00:00:00 2001 From: Muhammad Ibragimov Date: Thu, 21 Apr 2022 03:30:44 -0700 Subject: [PATCH] Resolve merge conflicts --- .../send_request.test.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/plugins/console/public/application/hooks/use_send_current_request/send_request.test.ts b/src/plugins/console/public/application/hooks/use_send_current_request/send_request.test.ts index d4d711baf435d..60ced085c6891 100644 --- a/src/plugins/console/public/application/hooks/use_send_current_request/send_request.test.ts +++ b/src/plugins/console/public/application/hooks/use_send_current_request/send_request.test.ts @@ -98,4 +98,37 @@ describe('sendRequest', () => { expect(mockedSendRequest).toHaveBeenCalledTimes(1); } }); + + describe('successful response value', () => { + describe('with text', () => { + it('should return value with lines separated', async () => { + mockedSendRequest.mockResolvedValue('\ntest_index-1 []\ntest_index-2 []\n'); + const response = await sendRequest({ + http: mockContextValue.services.http, + requests: [{ method: 'GET', url: 'test-1', data: [] }], + }); + + expect(response).toMatchInlineSnapshot(` + " + test_index-1 [] + test_index-2 [] + " + `); + expect(mockedSendRequest).toHaveBeenCalledTimes(1); + }); + }); + + describe('with parsed json', () => { + it('should stringify value', async () => { + mockedSendRequest.mockResolvedValue(JSON.stringify({ test: 'some value' })); + const response = await sendRequest({ + http: mockContextValue.services.http, + requests: [{ method: 'GET', url: 'test-2', data: [] }], + }); + + expect(typeof response).toBe('string'); + expect(mockedSendRequest).toHaveBeenCalledTimes(1); + }); + }); + }); });