Skip to content

Commit 022e4a2

Browse files
committed
add test for encoded querystring
1 parent c0d7f3a commit 022e4a2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/core/server/elasticsearch/client/configure_client.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,42 @@ describe('configureClient', () => {
179179
`);
180180
});
181181

182+
it('properly encode queries', () => {
183+
const client = configureClient(
184+
createFakeConfig({
185+
logQueries: true,
186+
}),
187+
{ logger, scoped: false }
188+
);
189+
190+
const response = createApiResponse({
191+
body: {},
192+
statusCode: 200,
193+
params: {
194+
method: 'GET',
195+
path: '/foo',
196+
querystring: { city: 'Münich' },
197+
},
198+
});
199+
200+
client.emit('response', null, response);
201+
202+
expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
203+
Array [
204+
Array [
205+
"200
206+
GET /foo
207+
city=M%C3%BCnich",
208+
Object {
209+
"tags": Array [
210+
"query",
211+
],
212+
},
213+
],
214+
]
215+
`);
216+
});
217+
182218
it('logs queries even in case of errors if `logQueries` is true', () => {
183219
const client = configureClient(
184220
createFakeConfig({

0 commit comments

Comments
 (0)