From 78815403206ce0154ba623d3b24a58444956614e Mon Sep 17 00:00:00 2001 From: Zhongnan Su Date: Tue, 18 May 2021 15:57:39 -0700 Subject: [PATCH] add test case for commit 368eb03e200b755870f1ad373e67561201ab6f31 (#370) Add missing test case for the fix "pass doc[field] == null" --- .../__tests__/savedSearchReportHelper.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kibana-reports/server/routes/utils/__tests__/savedSearchReportHelper.test.ts b/kibana-reports/server/routes/utils/__tests__/savedSearchReportHelper.test.ts index fd38dc9d..3a7a7ab2 100644 --- a/kibana-reports/server/routes/utils/__tests__/savedSearchReportHelper.test.ts +++ b/kibana-reports/server/routes/utils/__tests__/savedSearchReportHelper.test.ts @@ -278,6 +278,20 @@ describe('test create saved search report', () => { }, 20000); }); +test('create report for data set contains null field value', async () => { + const hits = [ + hit({ category: 'c1', customer_gender: 'Ma' }), + hit({ category: 'c2', customer_gender: 'le' }), + hit({ category: 'c3', customer_gender: null }), + ]; + const client = mockEsClient(hits); + const { dataUrl } = await createSavedSearchReport(input, client); + + expect(dataUrl).toEqual( + 'category,customer_gender\n' + 'c1,Ma\n' + 'c2,le\n' + 'c3, ' + ); +}, 20000); + /** * Mock Elasticsearch client and return different mock objects based on endpoint and parameters. */