2020-05-04 19:45:38 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2020-06-05 10:42:13 +01:00
|
|
|
import Vue from 'vue';
|
2020-05-04 19:45:38 +01:00
|
|
|
import Vuex from 'vuex';
|
|
|
|
|
|
|
|
import EstimationPeriodDropdown from '@/app/components/payments/EstimationPeriodDropdown.vue';
|
|
|
|
|
2020-06-10 12:46:02 +01:00
|
|
|
import { appStateModule } from '@/app/store/modules/appState';
|
2020-10-07 20:27:37 +01:00
|
|
|
import { newNodeModule, NODE_MUTATIONS } from '@/app/store/modules/node';
|
|
|
|
import { StorageNodeApi } from '@/storagenode/api/storagenode';
|
|
|
|
import { StorageNodeService } from '@/storagenode/sno/service';
|
|
|
|
import {
|
|
|
|
Dashboard,
|
|
|
|
Satellite,
|
2020-12-18 19:27:28 +00:00
|
|
|
SatelliteInfo, SatelliteScores,
|
2020-10-07 20:27:37 +01:00
|
|
|
Stamp,
|
|
|
|
Traffic,
|
|
|
|
} from '@/storagenode/sno/sno';
|
2020-05-04 19:45:38 +01:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
|
2020-10-07 20:27:37 +01:00
|
|
|
const nodeApi = new StorageNodeApi();
|
|
|
|
const nodeService = new StorageNodeService(nodeApi);
|
|
|
|
const nodeModule = newNodeModule(nodeService);
|
2020-06-10 12:46:02 +01:00
|
|
|
|
2020-05-04 19:45:38 +01:00
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
|
|
|
Vue.directive('click-outside', {
|
|
|
|
bind: (): void => { return; },
|
|
|
|
unbind: (): void => { return; },
|
|
|
|
});
|
|
|
|
|
2020-06-10 12:46:02 +01:00
|
|
|
const store = new Vuex.Store({ modules: { appStateModule, node: nodeModule }});
|
2020-05-04 19:45:38 +01:00
|
|
|
|
2020-10-09 12:18:26 +01:00
|
|
|
describe('EstimationPeriodDropdown', (): void => {
|
2020-05-04 19:45:38 +01:00
|
|
|
it('renders correctly', (): void => {
|
|
|
|
const wrapper = shallowMount(EstimationPeriodDropdown, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2020-06-10 12:46:02 +01:00
|
|
|
it('opens calendar on click only when historical data exists', async (): Promise<void> => {
|
|
|
|
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-06-10 12:46:02 +01:00
|
|
|
new Date(),
|
|
|
|
);
|
2020-05-04 19:45:38 +01:00
|
|
|
|
2020-06-10 12:46:02 +01:00
|
|
|
const dashboardInfo = new Dashboard(
|
|
|
|
'1',
|
|
|
|
'2',
|
2021-03-24 15:43:12 +00:00
|
|
|
[],
|
2020-06-10 12:46:02 +01:00
|
|
|
[
|
|
|
|
new SatelliteInfo('3', 'url1', null, null),
|
|
|
|
new SatelliteInfo('4', 'url2', new Date(), new Date(2020, 0, 1)),
|
|
|
|
],
|
2020-10-07 20:27:37 +01:00
|
|
|
new Traffic(99, 100, 4),
|
|
|
|
new Traffic(50),
|
2020-06-10 12:46:02 +01:00
|
|
|
new Date(),
|
|
|
|
new Date(),
|
|
|
|
'0.1.1',
|
|
|
|
'0.2.2',
|
|
|
|
false,
|
2021-12-21 05:33:57 +00:00
|
|
|
true,
|
|
|
|
'13000',
|
2020-06-10 12:46:02 +01:00
|
|
|
);
|
2020-05-04 19:45:38 +01:00
|
|
|
|
2020-06-10 12:46:02 +01:00
|
|
|
store.commit(NODE_MUTATIONS.POPULATE_STORE, dashboardInfo);
|
|
|
|
store.commit(NODE_MUTATIONS.SELECT_SATELLITE, satelliteInfo);
|
2020-05-04 19:45:38 +01:00
|
|
|
|
|
|
|
const wrapper = shallowMount(EstimationPeriodDropdown, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
});
|
|
|
|
|
|
|
|
wrapper.find('.period-container').trigger('click');
|
|
|
|
|
2020-06-10 12:46:02 +01:00
|
|
|
await localVue.nextTick();
|
|
|
|
expect(wrapper.find('.period-container__calendar').exists()).toBe(false);
|
|
|
|
|
|
|
|
satelliteInfo.joinDate = new Date(Date.UTC(2019, 10, 29));
|
|
|
|
|
|
|
|
store.commit(NODE_MUTATIONS.SELECT_SATELLITE, satelliteInfo);
|
|
|
|
|
|
|
|
wrapper.find('.period-container').trigger('click');
|
|
|
|
|
|
|
|
await localVue.nextTick();
|
2020-05-04 19:45:38 +01:00
|
|
|
expect(wrapper.find('.period-container__calendar').exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|