Skip to content

Commit

Permalink
Update charts; Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JackNeto committed Nov 17, 2019
1 parent 96b6e82 commit d70001b
Show file tree
Hide file tree
Showing 32 changed files with 871 additions and 1,643 deletions.
373 changes: 192 additions & 181 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "entaxy",
"description": "Your Personal Finance App",
"version": "0.1.0",
"version": "0.1.3",
"private": true,
"homepage": "https://entaxy.io",
"scripts": {
Expand All @@ -21,7 +21,7 @@
"debug": "echo 'chrome://inspect' && npx react-scripts --inspect-brk test --env=jsdom --runInBand --watch"
},
"dependencies": {
"@material-ui/core": "^4.5.1",
"@material-ui/core": "^4.6.1",
"@material-ui/icons": "^4.5.1",
"@mdi/js": "^4.5.95",
"@mdi/react": "^1.2.1",
Expand All @@ -40,32 +40,32 @@
"@vx/tooltip": "0.0.192",
"big.js": "^5.2.2",
"blockstack": "^19.2.5",
"chroma-js": "^2.0.4",
"chroma-js": "^2.1.0",
"classnames": "^2.2.6",
"d3": "^5.12.0",
"d3-array": "^2.3.3",
"d3-array": "^2.4.0",
"d3-sankey": "^0.12.3",
"date-fns": "^2.6.0",
"date-fns": "^2.7.0",
"formik": "^1.5.8",
"jsdom": "^15.2.0",
"jsdom": "^15.2.1",
"localforage": "^1.7.3",
"lodash": "^4.17.15",
"papaparse": "^5.1.0",
"pluralize": "^8.0.0",
"prop-types": "^15.7.2",
"query-string": "^6.8.3",
"react": "^16.11.0",
"query-string": "^6.9.0",
"react": "^16.12.0",
"react-confirm": "^0.1.18",
"react-date-range": "^1.0.0-beta",
"react-dom": "^16.11.0",
"react-dom": "^16.12.0",
"react-dropzone": "^10.1.10",
"react-motion": "^0.5.2",
"react-number-format": "^4.3.1",
"react-redux": "^7.1.1",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.2.0",
"react-select": "^3.0.8",
"react-virtualized": "^9.21.1",
"react-virtualized": "^9.21.2",
"react-window": "^1.8.5",
"recharts": "^1.8.5",
"recompose": "^0.30.0",
Expand All @@ -88,24 +88,25 @@
"not op_mini all"
],
"devDependencies": {
"@testing-library/jest-dom": "^4.2.0",
"@testing-library/react": "^9.3.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"coveralls": "^3.0.7",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.20.0",
"eslint-plugin-jest": "^23.0.4",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.2.0",
"eslint-plugin-react-hooks": "^2.3.0",
"history": "^4.10.1",
"http-proxy-middleware": "^0.20.0",
"husky": "^3.0.9",
"jest-enzyme": "^7.1.1",
"lint-staged": "^9.4.2",
"react-test-renderer": "^16.11.0",
"jest-enzyme": "^7.1.2",
"lint-staged": "^9.4.3",
"mq-polyfill": "^1.1.8",
"react-test-renderer": "^16.12.0",
"redux-mock-store": "^1.5.3"
},
"husky": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ exports[`ConfirmDialog matches snapshot 1`] = `
<ConfirmDialog proceed={[Function: mockConstructor]} cancel={[Function: bound cancel]} dismiss={[Function: mockConstructor]} show={true} title=\\"Title\\" description=\\"Description\\">
<WithStyles(ForwardRef(Dialog)) disableBackdropClick={true} disableEscapeKeyDown={true} maxWidth=\\"xs\\" aria-labelledby=\\"confirmation-dialog-title\\" open={true}>
<ForwardRef(Dialog) classes={{...}} disableBackdropClick={true} disableEscapeKeyDown={true} maxWidth=\\"xs\\" aria-labelledby=\\"confirmation-dialog-title\\" open={true}>
<ForwardRef(Modal) className=\\"MuiDialog-root\\" BackdropComponent={{...}} BackdropProps={{...}} closeAfterTransition={true} disableBackdropClick={true} disableEscapeKeyDown={true} onEscapeKeyDown={[undefined]} onClose={[undefined]} open={true} aria-labelledby=\\"confirmation-dialog-title\\">
<ForwardRef(Modal) className=\\"MuiDialog-root\\" BackdropComponent={{...}} BackdropProps={{...}} closeAfterTransition={true} disableBackdropClick={true} disableEscapeKeyDown={true} onEscapeKeyDown={[undefined]} onClose={[undefined]} open={true}>
<ForwardRef(Portal) container={[undefined]} disablePortal={false}>
<Portal containerInfo={{...}}>
<div onKeyDown={[Function: handleKeyDown]} role=\\"presentation\\" className=\\"MuiDialog-root\\" aria-labelledby=\\"confirmation-dialog-title\\" style={{...}}>
<div onKeyDown={[Function: handleKeyDown]} role=\\"presentation\\" className=\\"MuiDialog-root\\" style={{...}}>
<WithStyles(ForwardRef(Backdrop)) open={true} onClick={[Function: handleBackdropClick]} transitionDuration={{...}}>
<ForwardRef(Backdrop) classes={{...}} open={true} onClick={[Function: handleBackdropClick]} transitionDuration={{...}}>
<ForwardRef(Fade) in={true} timeout={{...}} onClick={[Function: handleBackdropClick]}>
Expand All @@ -23,9 +23,9 @@ exports[`ConfirmDialog matches snapshot 1`] = `
<ForwardRef(Fade) appear={true} in={true} timeout={{...}} onEnter={[Function: chainedFunction]} onEntering={[undefined]} onEntered={[undefined]} onExit={[undefined]} onExiting={[undefined]} onExited={[Function: chainedFunction]} role=\\"none presentation\\" tabIndex=\\"-1\\">
<Transition appear={true} in={true} onEnter={[Function: handleEnter]} onExit={[Function: handleExit]} timeout={{...}} onEntering={[Function: noop]} onEntered={[Function: noop]} onExiting={[Function: noop]} onExited={[Function: chainedFunction]} role=\\"none presentation\\" tabIndex=\\"-1\\" mountOnEnter={false} unmountOnExit={false} enter={true} exit={true}>
<div className=\\"MuiDialog-container MuiDialog-scrollPaper\\" onClick={[Function: handleBackdropClick]} onMouseDown={[Function: handleMouseDown]} style={{...}} role=\\"none presentation\\" tabIndex=\\"-1\\">
<WithStyles(ForwardRef(Paper)) elevation={24} role=\\"dialog\\" className=\\"MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs\\">
<ForwardRef(Paper) classes={{...}} elevation={24} role=\\"dialog\\" className=\\"MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs\\">
<div className=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiPaper-rounded\\" role=\\"dialog\\">
<WithStyles(ForwardRef(Paper)) elevation={24} role=\\"dialog\\" aria-describedby={[undefined]} aria-labelledby=\\"confirmation-dialog-title\\" className=\\"MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs\\">
<ForwardRef(Paper) classes={{...}} elevation={24} role=\\"dialog\\" aria-describedby={[undefined]} aria-labelledby=\\"confirmation-dialog-title\\" className=\\"MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs\\">
<div className=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiPaper-rounded\\" role=\\"dialog\\" aria-describedby={[undefined]} aria-labelledby=\\"confirmation-dialog-title\\">
<WithStyles(ForwardRef(DialogTitle)) id=\\"confirmation-dialog-title\\">
<ForwardRef(DialogTitle) classes={{...}} id=\\"confirmation-dialog-title\\">
<div className=\\"MuiDialogTitle-root\\" id=\\"confirmation-dialog-title\\">
Expand Down
2 changes: 1 addition & 1 deletion src/common/ConfirmDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ConfirmDialog.propTypes = {
show: PropTypes.bool.isRequired, // from confirmable. indicates if the dialog is shown or not.
proceed: PropTypes.func.isRequired, // from confirmable. call to close the dialog with promise resolved.
dismiss: PropTypes.func.isRequired, // from confirmable. call to only close the dialog.
title: PropTypes.string.isRequired, // the title of the dialog
title: PropTypes.node.isRequired, // the title of the dialog
description: PropTypes.string.isRequired // the description of the dialog
}

Expand Down
118 changes: 0 additions & 118 deletions src/common/Header/__tests__/__snapshots__/index.test.jsx.snap

This file was deleted.

70 changes: 58 additions & 12 deletions src/common/Header/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,69 @@
import React from 'react'
import renderer from 'react-test-renderer'
import { BrowserRouter } from 'react-router-dom'
import { render, fireEvent, waitForElement } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import { Provider } from 'react-redux'
import { store } from '../../../store'
import { Router } from 'react-router-dom'
import { createMemoryHistory } from 'history'
import configureMockStore from 'redux-mock-store'
import Header from '..'
import { initialState as userInitialState } from '../../../store/user/reducer'

jest.mock('../../LoginButton', () => 'LoginButton')
// https://github.com/mui-org/material-ui/issues/15726
global.document.createRange = () => ({
setStart: () => {},
setEnd: () => {},
commonAncestorContainer: {
nodeName: 'BODY',
ownerDocument: document
}
})

describe('Header', () => {
it('matches snapshot', () => {
const component = renderer.create((
const renderContent = () => {
const mockStore = configureMockStore()
const store = mockStore({ user: userInitialState })
const history = createMemoryHistory()

const props = {
match: { path: '/dashboard' }
}
return {
...render(
<Provider store={store}>
<BrowserRouter>
<Header match={{ path: '/dashboard' }}>
<Router history={history}>
<Header {...props}>
<div>content</div>
</Header>
</BrowserRouter>
</Router>
</Provider>
))
expect(component.toJSON()).toMatchSnapshot()
),
props,
history
}
}


describe('Header', () => {
it('renders correctly', () => {
const { getByText } = renderContent()

expect(getByText('Dashboard')).toBeInTheDocument()
expect(getByText('Budget')).toBeInTheDocument()
})

it('opens and closes menu', async () => {
const { getByText, queryByText, history } = renderContent()
const historyPushSpy = jest.spyOn(history, 'push')

expect(queryByText('Money Flow')).not.toBeInTheDocument()
expect(queryByText('History')).not.toBeInTheDocument()
expect(queryByText('Categories')).not.toBeInTheDocument()
// open the budget menu
fireEvent.click(getByText('Budget'))
waitForElement(() => getByText('Money Flow'))
expect(getByText('History')).toBeInTheDocument()
expect(getByText('Categories')).toBeInTheDocument()
// close the menu
fireEvent.click(getByText('Categories'))
expect(historyPushSpy).toHaveBeenCalledWith('/budget-categories')
})
})

0 comments on commit d70001b

Please sign in to comment.