diff --git a/public/mc.png b/public/mc.png deleted file mode 100644 index ebc9694..0000000 Binary files a/public/mc.png and /dev/null differ diff --git a/src/actions/actions.js b/src/actions/actions.js index 0fbfb4e..2d31107 100644 --- a/src/actions/actions.js +++ b/src/actions/actions.js @@ -23,23 +23,12 @@ export const changeCartoBBox = boundingbox => ({ }); -export const SET_PRICE = '@Filters/SET_PRICE'; -export const setPriceFilter = filter => ({ - type: SET_PRICE, - filter, -}); - export const SET_BBOX = '@Filters/SET_BBOX'; export const setBboxFilter = bbox => ({ type: SET_BBOX, bbox, }); -export const SET_NEIGHBOURHOODS = '@Filters/SET_NEIGHBOURHOODS'; -export const setNeighbourhoods = neighbourhoods => ({ - type: SET_NEIGHBOURHOODS, - neighbourhoods, -}); export const TOGGLE_LAYER = '@Layers/TOGGLE'; export const toggleLayer = name => ({ diff --git a/src/components/RightBar.js b/src/components/RightBar.js index 25d6ab1..152ec3f 100644 --- a/src/components/RightBar.js +++ b/src/components/RightBar.js @@ -29,6 +29,14 @@ class RightBar extends Component { operationColumn='total_damage' /> + ) diff --git a/src/data/layers/metro_lines.js b/src/data/layers/metro_lines.js deleted file mode 100644 index dba2ead..0000000 --- a/src/data/layers/metro_lines.js +++ /dev/null @@ -1,25 +0,0 @@ -export default { - name: '🚋 Metro Lines', - - visible: true, - - style: ` - #layer { - line-color: #FABADA; - line-width: 2px; - - line-color: ramp( - [name], - (#30a3dc,#cd031d,#ffe114,#944248,#96bf0d,#a0a5a7,#faa64a,#f27ca2,#a93094,#084594,#008b43,#a49a00,#00aa66,#0e4a97,#0066ff,#892ca0,#ff0000), - ("L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9", "L10", "L11", "L12", "L14", "R", "ML1", "ML2", "ML3"), "=" - ) - } - `, - - source: ` - SELECT cartodb_id, the_geom, the_geom_webmercator, name FROM jbotella.metro_lines - `, - - options: { - } -}; diff --git a/src/data/layers/metro_stations.js b/src/data/layers/metro_stations.js deleted file mode 100644 index 2efd4de..0000000 --- a/src/data/layers/metro_stations.js +++ /dev/null @@ -1,51 +0,0 @@ -export default { - name: '🚉 Metro Stations', - - visible: true, - - style: ` - #layer { - marker-width: 8; - marker-fill: #FFFFFF; - marker-line-width: 2; - marker-line-color: ramp( - [line], - (#30a3dc,#cd031d,#ffe114,#944248,#96bf0d,#a0a5a7,#faa64a,#f27ca2,#a93094,#084594,#008b43,#a49a00,#00aa66,#0e4a97,#0066ff,#892ca0,#ff0000), - ("L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9", "L10", "L11", "L12", "L14", "R", "ML1", "ML2", "ML3"), "=" - ); - marker-allow-overlap: true; - } - `, - - source: ` - SELECT - cartodb_id, - the_geom, - the_geom_webmercator, - line - FROM - linea1_geom_paradas_lite - `, - - // style: ` - // #layer { - // polygon-opacity: 0.2; - // polygon-fill: #56C58C; - // } - // `, - // - // source: ` - // WITH metro_areas as ( - // SELECT cartodb_id, ST_Buffer(the_geom::geography, 500)::geometry as the_geom FROM linea1_geom_paradas_lite - // ) - // - // SELECT - // metro_areas.cartodb_id, - // metro_areas.the_geom, - // ST_Transform(metro_areas.the_geom, 3857) as the_geom_webmercator - // FROM metro_areas - // `, - - options: { - }, -}; diff --git a/src/data/layers/neighbourhoods.js b/src/data/layers/neighbourhoods.js deleted file mode 100644 index a545b5a..0000000 --- a/src/data/layers/neighbourhoods.js +++ /dev/null @@ -1,19 +0,0 @@ -export default { - name: 'Neighbourhoods', - - visible: true, - - cartocss: ` - #layer { - line-color: #000; - line-opacity: 0.2; - } - `, - - query: ` - SELECT * FROM neighbourhoods - `, - - options: { - } -}; diff --git a/src/data/railLayer.js b/src/data/railLayer.js deleted file mode 100644 index 3462297..0000000 --- a/src/data/railLayer.js +++ /dev/null @@ -1,15 +0,0 @@ -export default { - style: ` - #layer { - marker-width: 7; - marker-fill: ramp([equipment_damage], (#f3e79b, #fac484, #f8a07e, #eb7f86, #ce6693, #a059a0, #5c53a5), quantiles); - marker-fill-opacity: 1; - marker-allow-overlap: true; - marker-line-width: 1; - marker-line-color: #FFFFFF; - marker-line-opacity: 1; - } - `, - - source: `SELECT * FROM rail_accidents` -}; diff --git a/src/data/utils.js b/src/data/utils.js deleted file mode 100644 index 85b8f3b..0000000 --- a/src/data/utils.js +++ /dev/null @@ -1,19 +0,0 @@ -export const formatPrice = (amount) => ( - (amount || 0).toLocaleString('es-ES', { - style: 'currency', - currency: 'EUR', - maximumFractionDigits: 2, - currencyDisplay: 'symbol' - }) -) - -export const debounce = (fn, time = 300) => { - let timeout; - - return function() { - const functionCall = () => fn.apply(this, arguments); - - clearTimeout(timeout); - timeout = setTimeout(functionCall, time); - } -} diff --git a/src/reducers/reducers.js b/src/reducers/reducers.js index 7615998..97a6199 100644 --- a/src/reducers/reducers.js +++ b/src/reducers/reducers.js @@ -88,48 +88,3 @@ export const layers = (state = DEFAULT_LAYERS, action) => { return state; } } - -const FILTERS_INITIAL_STATE = { - price: false, - bbox: false, - neighbourhoods: false, -} - -export const filters = (state = FILTERS_INITIAL_STATE, action) => { - switch (action.type) { - case actions.SET_PRICE: { - const { min, max } = action.filter; - - return { - ...state, - price: `price BETWEEN ${min} AND ${max}`, - }; - } - - case actions.SET_BBOX: { - const [ xmin, ymin, xmax, ymax ] = action.bbox; - - return { - ...state, - bbox: `ST_Intersects(the_geom_webmercator, ST_Transform(ST_MakeEnvelope(${xmin}, ${ymin}, ${xmax}, ${ymax}, 4326), 3857))`, - }; - } - - case actions.SET_NEIGHBOURHOODS: { - const neighbourhoods = action.neighbourhoods.map(name => `'${name}'`).join(','); - - if (neighbourhoods.length === 0) return { - ...state, - neighbourhoods: false, - }; - - return { - ...state, - neighbourhoods: `railroad IN (${neighbourhoods})`, - }; - } - - default: - return state; - } -} diff --git a/src/routers/AppRouter.js b/src/routers/AppRouter.js index 421c684..6bfca5c 100644 --- a/src/routers/AppRouter.js +++ b/src/routers/AppRouter.js @@ -10,6 +10,7 @@ const AppRouter = () => (
+
diff --git a/src/tests/__mocks__/moment.js b/src/tests/__mocks__/moment.js deleted file mode 100644 index 048f415..0000000 --- a/src/tests/__mocks__/moment.js +++ /dev/null @@ -1,5 +0,0 @@ -const moment = require.requireActual('moment'); - -export default (timestamp = 0) => { - return moment(timestamp) -} diff --git a/src/tests/actions/expenses.test.js b/src/tests/actions/expenses.test.js deleted file mode 100644 index c0693b5..0000000 --- a/src/tests/actions/expenses.test.js +++ /dev/null @@ -1,51 +0,0 @@ -import { addExpense, editExpense, removeExpense } from '../../actions/expenses'; - -test('should setup remove expense action object', () => { - const action = removeExpense({ id: '123abc' }); - expect(action).toEqual({ - type: 'REMOVE_EXPENSE', - id: '123abc' - }); -}); - -test('should setup edit expense action object', () => { - const action = editExpense('123abc', { note: 'New note value' }); - expect(action).toEqual({ - type: 'EDIT_EXPENSE', - id: '123abc', - updates: { - note: 'New note value' - } - }); -}); - -test('should setup add expense action object with provided values', () => { - const expenseData = { - description: 'Rent', - amount: 109500, - createdAt: 1000, - note: 'This was last months rent' - }; - const action = addExpense(expenseData); - expect(action).toEqual({ - type: 'ADD_EXPENSE', - expense: { - ...expenseData, - id: expect.any(String) - } - }); -}); - -test('should setup add expense action object with default values', () => { - const action = addExpense(); - expect(action).toEqual({ - type: 'ADD_EXPENSE', - expense: { - id: expect.any(String), - description: '', - note: '', - amount: 0, - createdAt: 0 - } - }); -}); diff --git a/src/tests/actions/filters.test.js b/src/tests/actions/filters.test.js deleted file mode 100644 index c4197e4..0000000 --- a/src/tests/actions/filters.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import moment from 'moment'; -import { - setStartDate, - setEndDate, - setTextFilter, - sortByAmount, - sortByDate -} from '../../actions/filters'; - -test('should generate set start date action object', () => { - const action = setStartDate(moment(0)); - expect(action).toEqual({ - type: 'SET_START_DATE', - startDate: moment(0) - }); -}); - -test('should generate set end date aciton object', () => { - const action = setEndDate(moment(0)); - expect(action).toEqual({ - type: 'SET_END_DATE', - endDate: moment(0) - }); -}); - -test('should generate set text filter object with text value', () => { - const text = 'Something in'; - const action = setTextFilter(text); - expect(action).toEqual({ - type: 'SET_TEXT_FILTER', - text - }); -}); - -test('should generate set text filter object with default', () => { - const action = setTextFilter(); - expect(action).toEqual({ - type: 'SET_TEXT_FILTER', - text: '' - }); -}); - -test('should generate action object for sort by date', () => { - expect(sortByDate()).toEqual({ type: 'SORT_BY_DATE' }); -}); - -test('should generate action object for sort by amount', () => { - expect(sortByAmount()).toEqual({ type: 'SORT_BY_AMOUNT' }); -}); diff --git a/src/tests/components/AddExpensePage.test.js b/src/tests/components/AddExpensePage.test.js deleted file mode 100644 index 318c811..0000000 --- a/src/tests/components/AddExpensePage.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import { AddExpensePage } from '../../components/AddExpensePage'; -import expenses from '../fixtures/expenses'; - -let addExpense, history, wrapper; - -beforeEach(() => { - addExpense = jest.fn() - history = { push: jest.fn() } - wrapper = shallow() -}) - -test('should render AddExpensePage correctly', () => { - expect(wrapper).toMatchSnapshot(); -}) - -test('should handle onSubmit correctly', () => { - wrapper.find('ExpenseForm').prop('onSubmit')(expenses[1]) - expect(history.push).toHaveBeenLastCalledWith('/') - expect(addExpense).toHaveBeenLastCalledWith(expenses[1]) -}) diff --git a/src/tests/components/EditExpensePage.test.js b/src/tests/components/EditExpensePage.test.js deleted file mode 100644 index 0cfb176..0000000 --- a/src/tests/components/EditExpensePage.test.js +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import { EditExpensePage } from '../../components/EditExpensePage'; -import expenses from '../fixtures/expenses'; - -let editExpense, removeExpense, history, wrapper; - -beforeEach(() => { - editExpense = jest.fn(); - removeExpense = jest.fn(); - history = { push: jest.fn() }; - wrapper = shallow( - - ) -}) - -test('should render EditExpensePage correctly', () => { - expect(wrapper).toMatchSnapshot(); -}) - -test('should handle editExpense correctly', () => { - wrapper.find('ExpenseForm').prop('onSubmit')(expenses[2]) - expect(history.push).toHaveBeenLastCalledWith('/') - expect(editExpense).toHaveBeenLastCalledWith(expenses[2].id, expenses[2]) -}) - -test('should handle removeExpense correctly', () => { - wrapper.find('button').simulate('click'); - expect(history.push).toHaveBeenLastCalledWith('/') - expect(removeExpense).toHaveBeenLastCalledWith({ - id: expenses[2].id - }) -}) diff --git a/src/tests/components/ExpenseDashboardPage.test.js b/src/tests/components/ExpenseDashboardPage.test.js deleted file mode 100644 index 798de17..0000000 --- a/src/tests/components/ExpenseDashboardPage.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import ExpenseDashboardPage from '../../components/ExpenseDashboardPage'; - -test('Should render ExpenseDashboardPage correctly', () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/src/tests/components/ExpenseForm.test.js b/src/tests/components/ExpenseForm.test.js deleted file mode 100644 index 56550e1..0000000 --- a/src/tests/components/ExpenseForm.test.js +++ /dev/null @@ -1,90 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import ExpenseForm from '../../components/ExpenseForm'; -import expenses from '../fixtures/expenses'; -import moment from 'moment' - -test('should render ExpenseForm correctly', () => { - const wrapper = shallow() - expect(wrapper).toMatchSnapshot(); -}) - -test('should render ExpenseForm with expense data', () => { - const wrapper = shallow() - expect(wrapper).toMatchSnapshot(); -}) - -test('should render error for invalid form submission', () => { - const wrapper = shallow() - wrapper.find('form').simulate('submit', { - preventDefault: () => { } - }) - expect(wrapper.state('error').length).toBeGreaterThan(0); - expect(wrapper).toMatchSnapshot(); -}) - -test('should set description on input change', () => { - const value = 'New description' - const wrapper = shallow() - wrapper.find('input').at(0).simulate('change', { - target: { value } - }) - expect(wrapper.state('description')).toBe(value); - expect(wrapper).toMatchSnapshot(); -}) - -test('should set note on text area change', () => { - const value = 'New note entry' - const wrapper = shallow() - wrapper.find('textarea').simulate('change', { - target: { value } - }) - expect(wrapper.state('note')).toBe(value); -}) - -test('should set amount if valid input', () => { - const value = '23.50' - const wrapper = shallow() - wrapper.find('input').at(1).simulate('change', { - target: { value } - }) - expect(wrapper.state('amount')).toBe(value); -}) - -test('should not set amount if invalid input', () => { - const value = '23.505' - const wrapper = shallow() - wrapper.find('input').at(1).simulate('change', { - target: { value } - }) - expect(wrapper.state('amount')).toBe(''); -}) - -test('should call onSubmit prop for valid form submission', () => { - const onSubmitSpy = jest.fn(); - const wrapper = shallow(); - wrapper.find('form').simulate('submit', { - preventDefault: () => { } - }); - expect(wrapper.state('error')).toBe(''); - expect(onSubmitSpy).toHaveBeenLastCalledWith({ - description: expenses[0].description, - amount: expenses[0].amount, - note: expenses[0].note, - createdAt: expenses[0].createdAt - }); -}); - -test('should set new date on date change', () => { - const now = moment(); - const wrapper = shallow() - wrapper.find('SingleDatePicker').prop('onDateChange')(now) - expect(wrapper.state('createdAt')).toEqual(now) -}) - -test('should set calendar focused on change', () => { - const focused = true - const wrapper = shallow() - wrapper.find('SingleDatePicker').prop('onFocusChange')({ focused }) - expect(wrapper.state('calendarFocused')).toEqual(focused) -}) diff --git a/src/tests/components/ExpenseList.test.js b/src/tests/components/ExpenseList.test.js deleted file mode 100644 index 2563a1f..0000000 --- a/src/tests/components/ExpenseList.test.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import { ExpenseList } from '../../components/ExpenseList'; -import expenses from '../fixtures/expenses'; - -test('Should render ExpenseList with expenses', () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); -}); - -test('Should render ExpenseList with empty message', () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/src/tests/components/ExpenseListFilters.test.js b/src/tests/components/ExpenseListFilters.test.js deleted file mode 100644 index 4815a4a..0000000 --- a/src/tests/components/ExpenseListFilters.test.js +++ /dev/null @@ -1,77 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import moment from 'moment'; -import { ExpenseListFilters } from '../../components/ExpenseListFilters'; -import { filters, altFilters } from '../fixtures/filters'; - -let setTextFilter, sortByDate, sortByAmount, setStartDate, setEndDate, wrapper; - -beforeEach(() => { - setTextFilter = jest.fn(); - sortByDate = jest.fn(); - sortByAmount = jest.fn(); - setStartDate = jest.fn(); - setEndDate = jest.fn(); - wrapper = shallow( - - ); -}); - -test('should render ExpenseListFilters correctly', () => { - expect(wrapper).toMatchSnapshot(); -}); - -test('should render ExpenseListFilters with alt data correctly', () => { - wrapper.setProps({ - filters: altFilters - }); - expect(wrapper).toMatchSnapshot(); -}); - -test('should handle text change', () => { - const value = 'rent'; - wrapper.find('input').simulate('change', { - target: { value } - }); - expect(setTextFilter).toHaveBeenLastCalledWith(value); -}); - -test('should sort by date', () => { - const value = 'date'; - wrapper.setProps({ - filters: altFilters - }); - wrapper.find('select').simulate('change', { - target: { value } - }); - expect(sortByDate).toHaveBeenCalled(); -}); - -test('should sort by amount', () => { - const value = 'amount'; - wrapper.find('select').simulate('change', { - target: { value } - }); - expect(sortByAmount).toHaveBeenCalled(); -}); - -test('should handle date changes', () => { - const startDate = moment(0).add(4, 'years'); - const endDate = moment(0).add(8, 'years'); - wrapper.find('DateRangePicker').prop('onDatesChange')({ startDate, endDate }); - expect(setStartDate).toHaveBeenLastCalledWith(startDate); - expect(setEndDate).toHaveBeenLastCalledWith(endDate); -}); - -test('hould handle date focus changes', () => { - const calendarFocused = 'endDate'; - wrapper.find('DateRangePicker').prop('onFocusChange')(calendarFocused); - expect(wrapper.state('calendarFocused')).toBe(calendarFocused); -}); diff --git a/src/tests/components/ExpenseListItem.test.js b/src/tests/components/ExpenseListItem.test.js deleted file mode 100644 index 04df21f..0000000 --- a/src/tests/components/ExpenseListItem.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import ExpenseListItem from '../../components/ExpenseListItem'; -import expenses from '../fixtures/expenses'; - -test('Should render ExpenseListItem correctly', () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/src/tests/components/Header.test.js b/src/tests/components/Header.test.js deleted file mode 100644 index 3aa711f..0000000 --- a/src/tests/components/Header.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import Header from '../../components/Header'; - -test('should render Header correctly', () => { - const wrapper = shallow(
); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/src/tests/components/NotFoundPage.test.js b/src/tests/components/NotFoundPage.test.js deleted file mode 100644 index 3d3d3c1..0000000 --- a/src/tests/components/NotFoundPage.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import NotFoundPage from '../../components/NotFoundPage'; -import expenses from '../fixtures/expenses'; - -test('Should render NotFoundPage correctly', () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/src/tests/components/__snapshots__/AddExpensePage.test.js.snap b/src/tests/components/__snapshots__/AddExpensePage.test.js.snap deleted file mode 100644 index 2b363b4..0000000 --- a/src/tests/components/__snapshots__/AddExpensePage.test.js.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render AddExpensePage correctly 1`] = ` -
-

- Add Expense -

- -
-`; diff --git a/src/tests/components/__snapshots__/EditExpensePage.test.js.snap b/src/tests/components/__snapshots__/EditExpensePage.test.js.snap deleted file mode 100644 index 5f9d8d1..0000000 --- a/src/tests/components/__snapshots__/EditExpensePage.test.js.snap +++ /dev/null @@ -1,23 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render EditExpensePage correctly 1`] = ` -
- - -
-`; diff --git a/src/tests/components/__snapshots__/ExpenseDashboardPage.test.js.snap b/src/tests/components/__snapshots__/ExpenseDashboardPage.test.js.snap deleted file mode 100644 index c7739d9..0000000 --- a/src/tests/components/__snapshots__/ExpenseDashboardPage.test.js.snap +++ /dev/null @@ -1,8 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Should render ExpenseDashboardPage correctly 1`] = ` -
- - -
-`; diff --git a/src/tests/components/__snapshots__/ExpenseForm.test.js.snap b/src/tests/components/__snapshots__/ExpenseForm.test.js.snap deleted file mode 100644 index fd996db..0000000 --- a/src/tests/components/__snapshots__/ExpenseForm.test.js.snap +++ /dev/null @@ -1,412 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render ExpenseForm correctly 1`] = ` -
-
- - - -