2020-05-07 20:08:57 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
|
|
|
|
import DiskStatChart from '@/app/components/DiskStatChart.vue';
|
|
|
|
|
2020-10-07 20:27:37 +01:00
|
|
|
import { newNodeModule, NODE_ACTIONS } from '@/app/store/modules/node';
|
2021-01-28 12:32:19 +00:00
|
|
|
import { Size } from '@/private/memory/size';
|
2020-10-07 20:27:37 +01:00
|
|
|
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
|
|
|
import { StorageNodeService } from '@/storagenode/sno/service';
|
|
|
|
import { Dashboard, SatelliteInfo, Traffic } from '@/storagenode/sno/sno';
|
2020-05-07 20:08:57 +01:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
2020-12-09 19:14:45 +00:00
|
|
|
localVue.filter('bytesToBase10String', (amountInBytes: number): string => {
|
2021-01-28 12:32:19 +00:00
|
|
|
return `${Size.toBase10String(amountInBytes)}`;
|
2020-12-09 19:14:45 +00:00
|
|
|
});
|
|
|
|
|
2020-10-07 20:27:37 +01:00
|
|
|
const nodeApi = new StorageNodeApi();
|
|
|
|
const nodeService = new StorageNodeService(nodeApi);
|
|
|
|
const nodeModule = newNodeModule(nodeService);
|
2020-05-07 20:08:57 +01:00
|
|
|
|
|
|
|
const store = new Vuex.Store({ modules: { node: nodeModule }});
|
|
|
|
|
|
|
|
describe('DiskStatChart', (): void => {
|
|
|
|
it('renders correctly', (): void => {
|
|
|
|
const wrapper = shallowMount(DiskStatChart, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with actual values', async (): Promise<void> => {
|
|
|
|
const wrapper = shallowMount(DiskStatChart, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
jest.spyOn(nodeApi, 'dashboard').mockReturnValue(
|
|
|
|
Promise.resolve(
|
|
|
|
new Dashboard(
|
|
|
|
'1',
|
|
|
|
'2',
|
2021-03-24 15:43:12 +00:00
|
|
|
[],
|
2020-05-07 20:08:57 +01:00
|
|
|
[
|
|
|
|
new SatelliteInfo('3', 'url1', null, null),
|
|
|
|
new SatelliteInfo('4', 'url2', new Date(2020, 1, 1), new Date(2020, 0, 1)),
|
|
|
|
],
|
2020-12-09 19:14:45 +00:00
|
|
|
new Traffic(550000, 1000000, 22000, 11000),
|
2020-10-07 20:27:37 +01:00
|
|
|
new Traffic(50),
|
2020-05-07 20:08:57 +01:00
|
|
|
new Date(),
|
|
|
|
new Date(2019, 3, 1),
|
|
|
|
'0.1.1',
|
|
|
|
'0.2.2',
|
|
|
|
false,
|
2021-12-21 05:33:57 +00:00
|
|
|
true,
|
|
|
|
'13000',
|
2020-05-07 20:08:57 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await store.dispatch(NODE_ACTIONS.GET_NODE_INFO);
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|