From 2847c7d852aa5f79076e274b3a65c9865270fce7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 23 Jul 2024 20:30:29 +0200 Subject: [PATCH] chore: add test for plot template merging --- tests/unit/plotTemplates.spec.ts | 48 +++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/unit/plotTemplates.spec.ts b/tests/unit/plotTemplates.spec.ts index 743030cd..e5a32915 100644 --- a/tests/unit/plotTemplates.spec.ts +++ b/tests/unit/plotTemplates.spec.ts @@ -2,8 +2,9 @@ import { describe, it, expect } from 'vitest'; import { usePlotTemplates } from '@/composables/plotTemplates'; import { PlotConfig } from '@/types'; +import { M } from 'vite/dist/node/types.d-aGj9QkWt'; -describe('plotTemplates.ts', () => { +describe('replaceTemplateColumns', () => { it('Updates main plot values', () => { const { replaceTemplateColumns } = usePlotTemplates(); const reMapping = { ema: 'ema_14' }; @@ -158,3 +159,48 @@ describe('plotTemplates.ts', () => { expect(replaceTemplateColumns(template, reMapping)).toEqual(expected); }); }); + +describe('applyPlotTemplate', () => { + it('Updates main plot values', () => { + const { applyPlotTemplate } = usePlotTemplates(); + const reMapping = { rsi: 'rsi_14' }; + + const currentConfig: PlotConfig = { + main_plot: { ema: { color: '#ff8000', type: 'line' } }, + subplots: { + MACD: { + macdsignal: { + color: '#ff8000', + type: 'line', + }, + macd: { + color: '#1370f4', + type: 'line', + }, + }, + }, + }; + const expected: Partial = { + main_plot: { ema: { color: '#ff8000', type: 'line' } }, + subplots: { + RSI: { + rsi_14: { + color: '#ff8000', + type: 'line', + }, + }, + MACD: { + macdsignal: { + color: '#ff8000', + type: 'line', + }, + macd: { + color: '#1370f4', + type: 'line', + }, + }, + }, + }; + expect(applyPlotTemplate('RSI', currentConfig, reMapping)).toEqual(expected); + }); +});