From 60ca15cc9d30899cb60f1422f7f2cbb85f63070d Mon Sep 17 00:00:00 2001 From: Jijeong Lee Date: Mon, 3 Jun 2024 12:38:44 -0700 Subject: [PATCH] add 'getUniqueLabelsForDays' test with duplicated labels --- www/__tests__/metricsHelper.test.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/www/__tests__/metricsHelper.test.ts b/www/__tests__/metricsHelper.test.ts index c914c5782..d573415d6 100644 --- a/www/__tests__/metricsHelper.test.ts +++ b/www/__tests__/metricsHelper.test.ts @@ -23,14 +23,23 @@ window['i18next'] = initializedI18next; describe('metricsHelper', () => { describe('getUniqueLabelsForDays', () => { - const days1 = [ - { mode_confirm_a: 1, mode_confirm_b: 2 }, - { mode_confirm_b: 1, mode_confirm_c: 3 }, - { mode_confirm_c: 1, mode_confirm_d: 3 }, - ] as any as DayOfMetricData[]; it("should return unique labels for days with 'mode_confirm_*'", () => { + const days1 = [ + { mode_confirm_a: 1, mode_confirm_b: 2 }, + { mode_confirm_b: 1, mode_confirm_c: 3 }, + { mode_confirm_c: 1, mode_confirm_d: 3 }, + ] as any as DayOfMetricData[]; expect(getUniqueLabelsForDays(days1)).toEqual(['a', 'b', 'c', 'd']); }); + + it('should return unique labels for days with duplicated labels', () => { + const days2 = [ + { mode_confirm_a: 1, mode_confirm_b: 2 }, + { mode_confirm_a: 1, mode_confirm_b: 2 }, + { mode_confirm_a: 1, mode_confirm_b: 2 }, + ] as any as DayOfMetricData[]; + expect(getUniqueLabelsForDays(days2)).toEqual(['a', 'b']); + }); }); describe('getLabelsForDay', () => {