Skip to content

Commit

Permalink
add test for encoded querystring
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Jul 7, 2020
1 parent c0d7f3a commit 022e4a2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/core/server/elasticsearch/client/configure_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,42 @@ describe('configureClient', () => {
`);
});

it('properly encode queries', () => {
const client = configureClient(
createFakeConfig({
logQueries: true,
}),
{ logger, scoped: false }
);

const response = createApiResponse({
body: {},
statusCode: 200,
params: {
method: 'GET',
path: '/foo',
querystring: { city: 'Münich' },
},
});

client.emit('response', null, response);

expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
Array [
Array [
"200
GET /foo
city=M%C3%BCnich",
Object {
"tags": Array [
"query",
],
},
],
]
`);
});

it('logs queries even in case of errors if `logQueries` is true', () => {
const client = configureClient(
createFakeConfig({
Expand Down

0 comments on commit 022e4a2

Please sign in to comment.