Skip to content
Snippets Groups Projects
Commit ff2e5502 authored by Briggs, Aaron Shane's avatar Briggs, Aaron Shane
Browse files

fixed tests added tests

parent ac2d8905
No related branches found
No related tags found
1 merge request!341Wdfn 742 replace download data js with vue
......@@ -46,8 +46,6 @@ describe('monitoring-location/components/hydrograph/data-table', () => {
const gwTable = testDiv.select('#gw-table-container').select('table');
expect(gwTable.select('caption').text()).toBe('Field visit data');
expect(gwTable.selectAll('tr').size()).toBe(5);
const downloadSection = testDiv.select('#download-graph-data-container-data-table');
expect(downloadSection.selectAll('input[type="radio"]').size()).toBe(3);
});
it('Shows single IV table if no GW levels', () => {
......@@ -93,56 +91,4 @@ describe('monitoring-location/components/hydrograph/data-table', () => {
expect(testDiv.select('#iv-table-container').style('display')).toBe('none');
expect(testDiv.select('#gw-table-container').style('display')).not.toBe('none');
});
it('Clicking the download button shows the download container', () => {
store = configureStore({
hydrographData: {
currentTimeRange: {
start: 1582560000000,
end: 1600620000000
},
primaryIVData: TEST_PRIMARY_IV_DATA
},
groundwaterLevelData: {
all: [TEST_GW_LEVELS]
},
hydrographState: {
selectedParameterCode: '72019',
selectedIVMethodID: '90649'
}
});
drawDataTables(testDiv, store, '11112222', 'USGS');
const downloadButton = testDiv.select('#download-graph-data-container-data-table-toggle');
expect(downloadButton.size()).toBe(1);
downloadButton.dispatch('click');
expect(testDiv.select('#download-graph-data-container-data-table').attr('hidden')).toBeNull();
});
it('Clicking the download button twice hides the download container', () => {
store = configureStore({
hydrographData: {
currentTimeRange: {
start: 1582560000000,
end: 1600620000000
},
primaryIVData: TEST_PRIMARY_IV_DATA
},
groundwaterLevelData: {
all: [TEST_GW_LEVELS]
},
hydrographState: {
selectedParameterCode: '72019',
selectedIVMethodID: '90649'
}
});
drawDataTables(testDiv, store, '11112222', 'USGS');
const downloadButton = testDiv.select('#download-graph-data-container-data-table-toggle');
downloadButton.dispatch('click');
downloadButton.dispatch('click');
expect(testDiv.select('#download-graph-data-container-data-table').attr('hidden')).not.toBeNull();
});
});
......@@ -363,9 +363,8 @@ describe('monitoring-location/components/hydrograph module', () => {
expect(selectAll('#change-time-span-container').size()).toBe(1);
});
it('should have two download data forms', () => {
it('should have one download container added with d3 (the vue component will not show in test)', () => {
expect(selectAll('#download-graph-data-container-select-actions').size()).toBe(1);
expect(selectAll('#download-graph-data-container-data-table').size()).toBe(1);
});
it('should have method select element', () => {
......
......@@ -10,6 +10,7 @@ import {configureStore} from 'ml/store';
import {TEST_PRIMARY_IV_DATA, TEST_GW_LEVELS} from '../mock-hydrograph-state';
import DataTable from './data-table.vue';
import DownloadData from './download-data.vue';
describe('monitoring-location/components/hydrograph/components/data-table.vue', () => {
let store;
......@@ -126,4 +127,49 @@ describe('monitoring-location/components/hydrograph/components/data-table.vue',
expect(wrapper.find('#iv-table-container').isVisible()).toBe(false);
expect(wrapper.find('#gw-table-container').isVisible()).toBe(true);
});
it('Shows only data retrieve button and download container', async() => {
store = configureStore({
hydrographData: {
currentTimeRange: {
start: 1582560000000,
end: 1600620000000
},
primaryIVData: TEST_PRIMARY_IV_DATA
},
groundwaterLevelData: {
all: []
},
hydrographState: {
selectedParameterCode: '72019',
selectedIVMethodID: '90649'
}
});
wrapper = mount(DataTable, {
global: {
plugins: [
[ReduxConnectVue, {
store,
mapDispatchToPropsFactory: (actionCreators) => (dispatch) => bindActionCreators(actionCreators, dispatch),
mapStateToPropsFactory: createStructuredSelector
}]
],
provide: {
store: store,
siteno: '11112222',
agencyCd: 'USGS',
buttonSetName: 'test-buttons'
}
}
});
expect(wrapper.findAll('button')).toHaveLength(1);
expect(wrapper.find('button').text()).toBe('Retrieve data');
expect(wrapper.findAllComponents(DownloadData)).toHaveLength(0);
await wrapper.find('button').trigger('click');
expect(wrapper.findAllComponents(DownloadData)).toHaveLength(1);
await wrapper.find('button').trigger('click');
expect(wrapper.findAllComponents(DownloadData)).toHaveLength(0);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment