2021-06-16 19:36:34 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
2022-11-04 11:57:05 +00:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
|
|
|
|
import store from '../../mock/store';
|
2021-06-16 19:36:34 +01:00
|
|
|
|
|
|
|
import BandwidthPage from '@/app/views/bandwidth/BandwidthPage.vue';
|
|
|
|
import { BandwidthTraffic } from '@/bandwidth';
|
|
|
|
import { Size } from '@/private/memory/size';
|
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
2021-08-02 18:09:54 +01:00
|
|
|
|
2021-06-16 19:36:34 +01:00
|
|
|
localVue.use(Vuex);
|
2021-08-02 18:09:54 +01:00
|
|
|
|
|
|
|
localVue.filter('bytesToBase10String', (amountInBytes: number): string => Size.toBase10String(amountInBytes));
|
2021-06-16 19:36:34 +01:00
|
|
|
|
|
|
|
const traffic = new BandwidthTraffic();
|
2021-08-02 18:09:54 +01:00
|
|
|
|
2021-06-16 19:36:34 +01:00
|
|
|
traffic.bandwidthSummary = 700000000;
|
|
|
|
traffic.egressSummary = 577700000000;
|
|
|
|
traffic.ingressSummary = 5000000;
|
|
|
|
|
|
|
|
describe('BandwidthPage', (): void => {
|
|
|
|
it('renders correctly', (): void => {
|
|
|
|
store.commit('bandwidth/populate', traffic);
|
|
|
|
|
|
|
|
const wrapper = shallowMount(BandwidthPage, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2021-08-02 18:09:54 +01:00
|
|
|
it('renders correctly with egress chart', async(): Promise<void> => {
|
2021-06-16 19:36:34 +01:00
|
|
|
const wrapper = shallowMount(BandwidthPage, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
await wrapper.findAll('.chart-container__title-area__chart-choice-item').at(1).trigger('click');
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2021-08-02 18:09:54 +01:00
|
|
|
it('renders correctly with ingress chart', async(): Promise<void> => {
|
2021-06-16 19:36:34 +01:00
|
|
|
const wrapper = shallowMount(BandwidthPage, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
await wrapper.findAll('.chart-container__title-area__chart-choice-item').at(2).trigger('click');
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|