storj/web/multinode/tests/unit/components/views/BandwidthPage.spec.ts
Egon Elbre 5e24060b25 web/multinode: switch to eslint
tslint has been deprecated so it's nice to switch to eslint.
Currently this uses a minimal eslint, to get things up and running.

Change-Id: If0ca6413b534b0aa15f6130a0a809e002d817356
2021-08-03 13:00:15 +03:00

59 lines
1.6 KiB
TypeScript

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
import Vuex from 'vuex';
import BandwidthPage from '@/app/views/bandwidth/BandwidthPage.vue';
import { BandwidthTraffic } from '@/bandwidth';
import { Size } from '@/private/memory/size';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import store from '../../mock/store';
const localVue = createLocalVue();
localVue.use(Vuex);
localVue.filter('bytesToBase10String', (amountInBytes: number): string => Size.toBase10String(amountInBytes));
const traffic = new BandwidthTraffic();
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();
});
it('renders correctly with egress chart', async(): Promise<void> => {
const wrapper = shallowMount(BandwidthPage, {
store,
localVue,
});
await wrapper.findAll('.chart-container__title-area__chart-choice-item').at(1).trigger('click');
expect(wrapper).toMatchSnapshot();
});
it('renders correctly with ingress chart', async(): Promise<void> => {
const wrapper = shallowMount(BandwidthPage, {
store,
localVue,
});
await wrapper.findAll('.chart-container__title-area__chart-choice-item').at(2).trigger('click');
expect(wrapper).toMatchSnapshot();
});
});