Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(log): environment based logging and feat(test): jest added for unit and integration testing #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('Main', () => {
test('main test', () => {
expect(true).toBe(true)
})
})

5 changes: 5 additions & 0 deletions __tests__/util/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Util', () => {
test('util test', () => {
expect(true).toBe(true)
})
})
5 changes: 3 additions & 2 deletions components/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DayPicker from 'react-day-picker'
import { connect } from 'react-redux'
import { updateGraph, selectFilter } from './Redux/actions'
import { rowsToGraph } from '../util/parse'
import { useLog } from '../util/logger'
import { isBrowser } from 'react-device-detect'

const Container = styled.div`
Expand Down Expand Up @@ -56,7 +57,7 @@ function DatePicker({ updateGraph, selectFilter }) {
const newDate = formatDate(date)

if (formatDate(selectedDay) !== newDate) {
console.log(newDate)
useLog(newDate)
changeSelectedDay(date)

const apiURL =
Expand All @@ -70,7 +71,7 @@ function DatePicker({ updateGraph, selectFilter }) {
})
.then(resp => resp.json())
.then(res => {
console.log(res)
useLog(res)
// Update the graph only if res.success is true
if(res.success){
updateGraph(rowsToGraph(res.data.rawPatientData))
Expand Down
5 changes: 3 additions & 2 deletions components/FilterPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
removeTravel,
} from '../../util/filters'
import { updateGraph, selectFilter } from '../Redux/actions'
import { useLog } from '../../util/logger'

const filters = [
{
Expand Down Expand Up @@ -106,7 +107,7 @@ const FilterPanel = ({
// const [selected, selectCategory] = React.useState('P2P')

const changeGraph = name => {
// console.log('Changegraph', graph, patients.byId)
// useLog('Changegraph', graph, patients.byId)
let currentFilter = _.find(filters, function(o) {
return o.name === filter
})
Expand All @@ -118,7 +119,7 @@ const FilterPanel = ({

selectFilter(name)
newGraph = choosenFilter.add(newGraph, patients.byId, states)
console.log(newGraph)
useLog(newGraph)
updateGraph(newGraph)
}
const FilterHeader = styled.div`
Expand Down
3 changes: 2 additions & 1 deletion components/NetworkMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { rowsToGraph, letterToCode } from '../../util/parse'
import normalize from '../../util/normalize'
import DatePicker from '../DatePicker'
import NetworkMapLegend from '../NetworkMapLegend'
import { useError } from '../../util/logger'

const NetworkMap = ({
filter,
Expand Down Expand Up @@ -61,7 +62,7 @@ const NetworkMap = ({
updateLastRefreshed(res.data.lastRefreshed)
setIsLoading(false)
})
.catch(err => console.log('error', err))
.catch(err => useError(err))
}, [isLoading])

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion components/Redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

// Action Types
import actionTypes from './actionTypes'
import { useLog } from '../../util/logger'

const updateGraph = graph => (dispatch, getState) => {
// Dispatch the result.
Expand Down Expand Up @@ -65,7 +66,7 @@ const setSearchTerm = term => (dispatch, getState) => {
}

const updateStates = states => (dispatch, getState) => {
console.log('Action updateStates', states);
useLog('Action updateStates', states);
dispatch({
type: actionTypes.UPDATE_STATES,
payload: {
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
verbose: true,
roots: ['__tests__'],
}
Loading