2020-05-20 18:10:15 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
|
|
|
|
import TotalPayoutArea from '@/app/components/TotalPayoutArea.vue';
|
|
|
|
|
2020-10-07 20:27:37 +01:00
|
|
|
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
2020-05-20 18:10:15 +01:00
|
|
|
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
2020-09-08 18:39:16 +01:00
|
|
|
import { Paystub, TotalHeldAndPaid } from '@/storagenode/payouts/payouts';
|
|
|
|
import { PayoutService } from '@/storagenode/payouts/service';
|
2020-05-20 18:10:15 +01:00
|
|
|
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();
|
2020-09-08 18:39:16 +01:00
|
|
|
const payoutService = new PayoutService(payoutApi);
|
2020-10-07 20:27:37 +01:00
|
|
|
const payoutModule = newPayoutModule(payoutService);
|
2020-05-20 18:10:15 +01:00
|
|
|
|
|
|
|
const store = new Vuex.Store({ modules: { payoutModule }});
|
|
|
|
|
2020-09-08 18:39:16 +01:00
|
|
|
describe('TotalPayoutArea', (): void => {
|
2020-05-20 18:10:15 +01:00
|
|
|
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,
|
|
|
|
});
|
2020-09-08 18:39:16 +01:00
|
|
|
const paystub = new Paystub();
|
|
|
|
paystub.held = 600000;
|
|
|
|
paystub.disposed = 100000;
|
|
|
|
paystub.paid = 1000000;
|
2020-05-20 18:10:15 +01:00
|
|
|
|
2020-09-08 18:39:16 +01:00
|
|
|
const totalHeldAndPaid = new TotalHeldAndPaid([paystub]);
|
|
|
|
totalHeldAndPaid.setCurrentMonthEarnings(40000);
|
|
|
|
|
|
|
|
await store.commit(PAYOUT_MUTATIONS.SET_TOTAL, totalHeldAndPaid);
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
|
|
|
|
totalHeldAndPaid.held = 400000;
|
|
|
|
|
|
|
|
await store.commit(PAYOUT_MUTATIONS.SET_TOTAL, totalHeldAndPaid);
|
2020-05-20 18:10:15 +01:00
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|