Added order control to countries graph

This commit is contained in:
Alejandro Celaya
2018-10-28 22:54:08 +01:00
parent 6634fc41c5
commit 368de2b4c7
8 changed files with 119 additions and 34 deletions

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { DropdownItem } from 'reactstrap';
import { values } from 'ramda';
import { identity, values } from 'ramda';
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
import caretDownIcon from '@fortawesome/fontawesome-free-solid/faCaretDown';
import * as sinon from 'sinon';
@@ -15,7 +15,7 @@ describe('<SortingDropdown />', () => {
baz: 'Hello World',
};
const createWrapper = (props) => {
wrapper = shallow(<SortingDropdown items={items} {...props} />);
wrapper = shallow(<SortingDropdown items={items} onChange={identity} {...props} />);
return wrapper;
};
@@ -26,8 +26,9 @@ describe('<SortingDropdown />', () => {
const wrapper = createWrapper();
const dropdownItems = wrapper.find(DropdownItem);
const secondIndex = 2;
const clearItemsCount = 2;
expect(dropdownItems).toHaveLength(values(items).length);
expect(dropdownItems).toHaveLength(values(items).length + clearItemsCount);
expect(dropdownItems.at(0).html()).toContain('Foo');
expect(dropdownItems.at(1).html()).toContain('Bar');
expect(dropdownItems.at(secondIndex).html()).toContain('Hello World');

View File

@@ -7,6 +7,7 @@ import { ShortUrlsVisitsComponent as ShortUrlsVisits } from '../../src/visits/Sh
import MutedMessage from '../../src/utils/MuttedMessage';
import GraphCard from '../../src/visits/GraphCard';
import DateInput from '../../src/common/DateInput';
import CountriesGraph from '../../src/visits/CountriesGraph';
describe('<ShortUrlVisits />', () => {
let wrapper;
@@ -69,9 +70,11 @@ describe('<ShortUrlVisits />', () => {
it('renders all graphics when visits are properly loaded', () => {
const wrapper = createComponent({ loading: false, error: false, visits: [{}, {}, {}] });
const graphs = wrapper.find(GraphCard);
const expectedGraphsCount = 4;
const countriesGraphs = wrapper.find(CountriesGraph);
const expectedGraphsCount = 3;
expect(graphs).toHaveLength(expectedGraphsCount);
expect(countriesGraphs).toHaveLength(1);
});
it('reloads visits when selected dates change', () => {