Skip to content

Commit

Permalink
chore: update settings store test
Browse files Browse the repository at this point in the history
  • Loading branch information
begprod committed Aug 7, 2024
1 parent 09ec37d commit b6d00df
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/stores/settings/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('€');
Expand All @@ -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', () => {
Expand Down

0 comments on commit b6d00df

Please sign in to comment.