chore: add test for plot template merging

This commit is contained in:
Matthias 2024-07-23 20:30:29 +02:00
parent 8cb21af220
commit 2847c7d852

View File

@ -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<PlotConfig> = {
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);
});
});