2020-07-22 16:15:24 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
|
|
|
|
import TotalHeldArea from '@/app/components/payments/TotalHeldArea.vue';
|
|
|
|
|
2020-10-07 20:27:37 +01:00
|
|
|
import { newNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
|
|
|
import { newPayoutModule, PAYOUT_MUTATIONS } from '@/app/store/modules/payout';
|
2020-07-22 16:15:24 +01:00
|
|
|
import { PayoutHttpApi } from '@/storagenode/api/payout';
|
2020-10-07 20:27:37 +01:00
|
|
|
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
2021-01-18 20:49:28 +00:00
|
|
|
import { Paystub, TotalPayments } from '@/storagenode/payouts/payouts';
|
2020-07-22 16:15:24 +01:00
|
|
|
import { PayoutService } from '@/storagenode/payouts/service';
|
2020-10-07 20:27:37 +01:00
|
|
|
import { StorageNodeService } from '@/storagenode/sno/service';
|
2020-12-18 19:27:28 +00:00
|
|
|
import { Metric, Satellite, SatelliteScores, Stamp } from '@/storagenode/sno/sno';
|
2020-07-22 16:15:24 +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();
|
|
|
|
const payoutService = new PayoutService(payoutApi);
|
2020-10-07 20:27:37 +01:00
|
|
|
const payoutModule = newPayoutModule(payoutService);
|
|
|
|
const nodeApi = new StorageNodeApi();
|
|
|
|
const nodeService = new StorageNodeService(nodeApi);
|
|
|
|
const nodeModule = newNodeModule(nodeService);
|
2020-07-22 16:15:24 +01:00
|
|
|
|
|
|
|
const store = new Vuex.Store({ modules: { payoutModule, node: nodeModule }});
|
|
|
|
|
|
|
|
describe('TotalHeldArea', (): void => {
|
|
|
|
it('renders correctly', (): void => {
|
|
|
|
const wrapper = shallowMount(TotalHeldArea, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with actual values', async (): Promise<void> => {
|
|
|
|
const wrapper = shallowMount(TotalHeldArea, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
const testJoinAt = new Date(Date.UTC(2018, 0, 30));
|
|
|
|
|
|
|
|
const satelliteInfo = new Satellite(
|
|
|
|
'3',
|
|
|
|
[new Stamp()],
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
111,
|
|
|
|
222,
|
|
|
|
50,
|
|
|
|
70,
|
2020-12-18 19:27:28 +00:00
|
|
|
new SatelliteScores('', 1, 0, 0),
|
2020-07-22 16:15:24 +01:00
|
|
|
testJoinAt,
|
|
|
|
);
|
|
|
|
const paystub = new Paystub();
|
|
|
|
paystub.held = 600000;
|
|
|
|
paystub.disposed = 100000;
|
|
|
|
paystub.paid = 1000000;
|
|
|
|
|
2021-01-18 20:49:28 +00:00
|
|
|
const totalPayments = new TotalPayments([paystub]);
|
2020-07-22 16:15:24 +01:00
|
|
|
|
|
|
|
await store.commit(NODE_MUTATIONS.SELECT_SATELLITE, satelliteInfo);
|
|
|
|
|
2021-01-18 20:49:28 +00:00
|
|
|
await store.commit(PAYOUT_MUTATIONS.SET_TOTAL, totalPayments);
|
2020-07-22 16:15:24 +01:00
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|