storj/web/storagenode/tests/unit/components/payments/TotalPayoutArea.spec.ts
NickolaiYurchenko 212baf6145 web/storagenode: balance section markup, current month estimated payout frontend implementation
Change-Id: I8820c842e2773a114423eab8370b5c4dc8f73cdd
2021-02-18 09:52:58 +02:00

61 lines
1.8 KiB
TypeScript

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
import Vuex from 'vuex';
import TotalPayoutArea from '@/app/components/TotalPayoutArea.vue';
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
import { PayoutHttpApi } from '@/storagenode/api/payout';
import { Paystub, TotalPayments } from '@/storagenode/payouts/payouts';
import { PayoutService } from '@/storagenode/payouts/service';
import { createLocalVue, shallowMount } from '@vue/test-utils';
const localVue = createLocalVue();
localVue.use(Vuex);
localVue.filter('centsToDollars', (cents: number): string => {
return `$${(cents / 100).toFixed(2)}`;
});
const payoutApi = new PayoutHttpApi();
const payoutService = new PayoutService(payoutApi);
const payoutModule = newPayoutModule(payoutService);
const store = new Vuex.Store({ modules: { payoutModule }});
describe('TotalPayoutArea', (): void => {
it('renders correctly', (): void => {
const wrapper = shallowMount(TotalPayoutArea, {
store,
localVue,
});
expect(wrapper).toMatchSnapshot();
});
it('renders correctly with actual values', async (): Promise<void> => {
const wrapper = shallowMount(TotalPayoutArea, {
store,
localVue,
});
const paystub = new Paystub();
paystub.held = 600000;
paystub.disposed = 100000;
paystub.paid = 1000000;
const totalPayments = new TotalPayments([paystub]);
totalPayments.setCurrentMonthEarnings(40000);
await store.commit(PAYOUT_MUTATIONS.SET_TOTAL, totalPayments);
expect(wrapper).toMatchSnapshot();
totalPayments.held = 400000;
await store.commit(PAYOUT_MUTATIONS.SET_TOTAL, totalPayments);
expect(wrapper).toMatchSnapshot();
});
});