From b6d00df7498e4dff4a97baad3a9e505f6e2c6f1a Mon Sep 17 00:00:00 2001 From: Andrey Aratov Date: Wed, 7 Aug 2024 17:03:28 +0300 Subject: [PATCH] chore: update settings store test --- src/stores/settings/settings.spec.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/stores/settings/settings.spec.ts b/src/stores/settings/settings.spec.ts index 74d4b50..5728ff5 100644 --- a/src/stores/settings/settings.spec.ts +++ b/src/stores/settings/settings.spec.ts @@ -8,8 +8,21 @@ describe('Settings store', () => { setActivePinia(pinia); const settingsStore = useSettingsStore(); - const { currencies, dailyBudget, getActiveCurrency } = storeToRefs(settingsStore); - const { setActiveCurrency, setDailyBudget, addNewCurrency, deleteCurrency } = settingsStore; + const { currencies, dailyBudget, getMonthlyDailyBudget, getActiveCurrency } = + storeToRefs(settingsStore); + const { + initMonthlyDailyBudgetObject, + setActiveCurrency, + setDailyBudget, + addNewCurrency, + deleteCurrency, + } = settingsStore; + + it('should initialize monthly daily budget object', () => { + initMonthlyDailyBudgetObject(); + + expect(Object.keys(getMonthlyDailyBudget.value).length).toEqual(7); + }); it('should set active currency', () => { setActiveCurrency('€'); @@ -18,9 +31,18 @@ describe('Settings store', () => { }); it('should set daily budget', () => { + const currentMonth = Object.keys(getMonthlyDailyBudget.value).find( + (key: string) => getMonthlyDailyBudget.value[key].isCurrent, + ); + setDailyBudget(1000); + const currentMonthDailyBudget = currentMonth + ? getMonthlyDailyBudget.value[currentMonth].dailyBudget + : NaN; + expect(dailyBudget.value).toEqual(1000); + expect(currentMonthDailyBudget).toEqual(1000); }); it('should add new currency', () => {