Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Ibragimov committed Apr 20, 2022
1 parent a4dd9c0 commit 45e6d68
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,36 @@ describe('sendRequestToES', () => {
expect(mockedSendRequestToES).toHaveBeenCalledTimes(1);
}
});
describe('successful response value', () => {
describe('with text', () => {
it('should return value with lines separated', async () => {
mockedSendRequestToES.mockResolvedValue('\ntest_index-1 [] \ntest_index-2 []\n');
const response = await sendRequestToES({
http: mockContextValue.services.http,
requests: [{ method: 'GET', url: 'test-1', data: [] }],
});

expect(response).toMatchInlineSnapshot(`
"
test_index-1 []
test_index-2 []
"
`);
expect(mockedSendRequestToES).toHaveBeenCalledTimes(1);
});
});

describe('with parsed json', () => {
it('should stringify value', async () => {
mockedSendRequestToES.mockResolvedValue(JSON.stringify({ test: 'some value' }));
const response = await sendRequestToES({
http: mockContextValue.services.http,
requests: [{ method: 'GET', url: 'test-2', data: [] }],
});

expect(typeof response).toBe('string');
expect(mockedSendRequestToES).toHaveBeenCalledTimes(1);
});
});
});
});

0 comments on commit 45e6d68

Please sign in to comment.