From 8cb21af22062e34f64598732a1d7ee326a6ddac2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 23 Jul 2024 20:27:13 +0200 Subject: [PATCH] fix: Re-map fill_to values, too --- src/composables/plotTemplates.ts | 8 +++++ tests/unit/plotTemplates.spec.ts | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/src/composables/plotTemplates.ts b/src/composables/plotTemplates.ts index 1cb98813..a095b862 100644 --- a/src/composables/plotTemplates.ts +++ b/src/composables/plotTemplates.ts @@ -50,6 +50,10 @@ function replaceTemplateColumns(template: Partial, nameMap: Record, nameMap: Record { }; expect(replaceTemplateColumns(template, reMapping)).toEqual(expected); }); + + it('Updates "fill to" values', () => { + const { replaceTemplateColumns } = usePlotTemplates(); + const reMapping = { + bb_upperband: 'upperband', + bb_lowerband: 'lowerband', + macd: 'macd_5m', + }; + const template: Partial = { + main_plot: { + bb_upperband: { + color: '#008af4', + type: 'line', + fill_to: 'bb_lowerband', + }, + bb_lowerband: { + color: '#008af4', + type: 'line', + }, + }, + subplots: { + MACD: { + macdsignal: { + color: '#ff8000', + type: 'line', + fill_to: 'macd', + }, + macd: { + color: '#1370f4', + type: 'line', + }, + }, + }, + }; + const expected: Partial = { + main_plot: { + upperband: { + color: '#008af4', + type: 'line', + fill_to: 'lowerband', + }, + lowerband: { + color: '#008af4', + type: 'line', + }, + }, + subplots: { + MACD: { + macdsignal: { + color: '#ff8000', + type: 'line', + fill_to: 'macd_5m', + }, + macd_5m: { + color: '#1370f4', + type: 'line', + }, + }, + }, + }; + expect(replaceTemplateColumns(template, reMapping)).toEqual(expected); + }); });