Commit 86133c1e authored by Martin Fahl's avatar Martin Fahl

refactors ' to " and removes ; also removes app.css

parent d60030a1
import * as actions from '.';
import * as actions from '.'
import * as types from '../constants/ActionTypes'
describe('actions', () => {
......
import Axios from 'axios';
import * as types from '../constants/ActionTypes'
import Axios from "axios"
import * as types from "../constants/ActionTypes"
export const itemAdded = (id, name, quantity) => ({
type: types.ITEM_ADDED,
......@@ -49,20 +49,20 @@ export const itemsLoaded = (items) => ({
})
export const getAllItems = () => dispatch => {
return Axios.get('/api/items').then((response) => dispatch(itemsLoaded(response.data)))
return Axios.get("/api/items").then((response) => dispatch(itemsLoaded(response.data)))
}
export const addItem = (name, quantity) => dispatch => {
return Axios.post('/api/items', {name, quantity}).then((response) => dispatch(itemAdded(response.data.id, response.data.name, response.data.quantity)))
return Axios.post("/api/items", {name, quantity}).then((response) => dispatch(itemAdded(response.data.id, response.data.name, response.data.quantity)))
}
export const deleteItem = (id) => dispatch => {
return Axios.delete('/api/items/'+id).then(dispatch(itemDeleted(id)))
return Axios.delete("/api/items/"+id).then(dispatch(itemDeleted(id)))
}
export const updateItem = (id, name, quantity) => dispatch => {
dispatch(itemUpdated(id, name, quantity))
debounced(500, Axios.put('/api/items/'+id, {id, name, quantity}).catch(dispatch(getAllItems)))
debounced(500, Axios.put("/api/items/"+id, {id, name, quantity}).catch(dispatch(getAllItems)))
}
const debounced = (delay, fn) => {
......
import React from "react";
import PropTypes from "prop-types";
import {Button, TextField, Dialog, DialogActions, DialogContent, DialogTitle, Grid } from '@material-ui/core/';
import React from "react"
import PropTypes from "prop-types"
import {Button, TextField, Dialog, DialogActions, DialogContent, DialogTitle, Grid } from "@material-ui/core/"
const AddDialog = ({ name, quantity, isOpen, handleClose, handleCancel, handleAdd, updateName, updateQuantity }) => (
<Dialog
......
import React from "react";
import React from "react"
const AddDialog = () => <div name="AddDialog" />
......
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}
.App-title {
font-size: 1.5em;
}
.App-intro {
font-size: large;
}
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
import React from 'react';
import Navbar from "../Navbar/Navbar";
import CodecentricFooter from "../CodecentricFooter/CodecentricFooter";
import InventoryListContainer from '../../container/InventoryListContainer/InventoryListContainer';
import { withStyles } from '@material-ui/core/styles'
import React from "react"
import Navbar from "../Navbar/Navbar"
import CodecentricFooter from "../CodecentricFooter/CodecentricFooter"
import InventoryListContainer from "../../container/InventoryListContainer/InventoryListContainer"
import { withStyles } from "@material-ui/core/styles"
const styles = {
root: {
......@@ -20,6 +20,6 @@ const App = (props) => (
<CodecentricFooter author="codecentric" link="https://www.codecentric.de"/>
</div>
);
)
export default withStyles(styles)(App)
\ No newline at end of file
......@@ -10,11 +10,11 @@ const CodecentricFooter = ({author, link}) => (
</Typography>
</Grid>
</Grid>
);
)
CodecentricFooter.propTypes = {
author: PropTypes.string,
link: PropTypes.string
};
}
export default CodecentricFooter
\ No newline at end of file
......@@ -8,5 +8,5 @@ describe("CodecentricFooter", () => {
.create(<CodecentricFooter author="Test" link="http://www.google.de" />)
.toJSON();
expect(codecentricFooterComponent).toMatchSnapshot();
});
});
})
})
import React from 'react';
import logo from '../../images/CC_RGB_onBlack.png'; // Tell Webpack this JS file uses this image
import React from "react";
import logo from "../../images/CC_RGB_onBlack.png"
const CodecentricLogo = () => (
<img src={logo} height="60" alt="codecentric" />
);
)
export default CodecentricLogo
\ No newline at end of file
import React from "react";
import PropTypes from "prop-types";
import TextField from '@material-ui/core/TextField';
import Icon from '@material-ui/core/Icon';
import InputAdornment from '@material-ui/core/InputAdornment';
import React from "react"
import PropTypes from "prop-types"
import { TextField, Icon, InputAdornment } from "@material-ui/core/"
const Filter = ({ filterTerm, updateFilter }) => (
<TextField
......@@ -20,11 +18,11 @@ const Filter = ({ filterTerm, updateFilter }) => (
}}
/>
);
)
Filter.propTypes = {
filterTerm: PropTypes.string,
updateFilter: PropTypes.func
};
}
export default Filter
\ No newline at end of file
......@@ -9,7 +9,7 @@ describe("Filter", () => {
.create(<Filter filterTerm="filter" updateFilter={() => {}} />)
.toJSON();
expect(filterComponent).toMatchSnapshot();
});
})
it("should call 'updateFilter' when the input fields changes", () => {
const updateFilter = jest.fn();
......@@ -21,5 +21,5 @@ describe("Filter", () => {
filterComponent.find("#input-with-icon-textfield").simulate("change");
expect(updateFilter.mock.calls.length).toBe(1);
});
});
})
})
import React from "react";
import InventoryList from "./InventoryList";
import renderer from "react-test-renderer";
import React from "react"
import InventoryList from "./InventoryList"
import renderer from "react-test-renderer"
jest.mock('../Filter/Filter')
jest.mock('../../container/ItemContainer/ItemContainer')
jest.mock('../../container/AddDialogContainer/AddDialogContainer')
jest.mock("../Filter/Filter")
jest.mock("../../container/ItemContainer/ItemContainer")
jest.mock("../../container/AddDialogContainer/AddDialogContainer")
describe("InventoryList", () => {
it("should render as expected", () => {
......@@ -16,6 +16,6 @@ describe("InventoryList", () => {
.create(<InventoryList items={itemList} />)
.toJSON();
expect(inventoryListComponent).toMatchSnapshot();
});
})
});
})
import React from "react";
import PropTypes from "prop-types";
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import Typography from '@material-ui/core/Typography';
import Icon from '@material-ui/core/Icon';
import IconButton from '@material-ui/core/IconButton';
import DeleteIcon from '@material-ui/icons/Delete';
import Avatar from '@material-ui/core/Avatar';
import React from "react"
import PropTypes from "prop-types"
import { ListItem, ListItemText, Typography, Icon, IconButton, Avatar } from "@material-ui/core/"
import DeleteIcon from "@material-ui/icons/Delete"
const increment = (quantity) => quantity + 1
const decrement = (quantity) => quantity > 1 ? quantity - 1 : 0
......@@ -44,6 +39,6 @@ Item.propTypes = {
increment: PropTypes.func,
decrement: PropTypes.func,
deleteItem: PropTypes.func
};
}
export default Item
\ No newline at end of file
import React from 'react';
import PropTypes from "prop-types";
import CodecentricLogo from "../CodecentricLogo/CodecentricLogo";
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import React from "react"
import PropTypes from "prop-types"
import CodecentricLogo from "../CodecentricLogo/CodecentricLogo"
import AppBar from "@material-ui/core/AppBar"
import Toolbar from "@material-ui/core/Toolbar"
import Typography from "@material-ui/core/Typography"
const Navbar = ({appName}) => (
<AppBar position="static" color="primary">
......@@ -15,10 +15,10 @@ const Navbar = ({appName}) => (
</Toolbar>
</AppBar>
);
)
Navbar.propTypes = {
appName: PropTypes.string
};
}
export default Navbar
\ No newline at end of file
import React from "react";
import Navbar from "./Navbar";
import renderer from "react-test-renderer";
import { shallow } from "enzyme";
import React from "react"
import Navbar from "./Navbar"
import renderer from "react-test-renderer"
describe("Navbar", () => {
it("should render as expected", () => {
......@@ -9,5 +8,5 @@ describe("Navbar", () => {
.create(<Navbar appName="Test" />)
.toJSON();
expect(navbarComponent).toMatchSnapshot();
});
});
})
})
import { connect } from 'react-redux'
import Item from '../../components/Item/Item'
import { updateItem, deleteItem } from '../../actions'
import { createSelector } from 'reselect'
import { connect } from "react-redux"
import Item from "../../components/Item/Item"
import { updateItem, deleteItem } from "../../actions"
import { createSelector } from "reselect"
const getItem = (state, props) => state.items.find(item => item.id === props.id)
......
import React from 'react';
import { render } from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk';
import { Provider } from 'react-redux'
import registerServiceWorker from './registerServiceWorker';
import rootReducer from './reducers'
import App from './components/App/App';
import React from "react";
import { render } from "react-dom"
import { createStore, applyMiddleware } from "redux"
import thunk from "redux-thunk";
import { Provider } from "react-redux"
import registerServiceWorker from "./registerServiceWorker";
import rootReducer from "./reducers"
import App from "./components/App/App";
const store = createStore(
rootReducer,
applyMiddleware(thunk)
);
console.log('initial state: ', store.getState());
console.log("initial state: ", store.getState());
store.subscribe(() => {
console.log(store.getState());
});
......@@ -21,6 +21,6 @@ render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
document.getElementById("root")
)
registerServiceWorker();
import { OPEN_ADD_DIALOG, CLOSE_ADD_DIALOG, UPDATE_ADD_DIALOG_NAME, UPDATE_ADD_DIALOG_QUANTITY } from '../constants/ActionTypes'
import { OPEN_ADD_DIALOG, CLOSE_ADD_DIALOG, UPDATE_ADD_DIALOG_NAME, UPDATE_ADD_DIALOG_QUANTITY } from "../constants/ActionTypes"
const addDialog = (state = {isOpen: false, name: "", quantity: 0}, action) => {
switch (action.type) {
......
import reducer from './addDialog'
import * as types from '../constants/ActionTypes'
import reducer from "./addDialog"
import * as types from "../constants/ActionTypes"
describe('addDialog reducer', () => {
it('should return the initial state', () => {
describe("addDialog reducer", () => {
it("should return the initial state", () => {
expect(reducer(undefined, {})).toEqual(
{isOpen: false, name: "", quantity: 0}
)
})
it('should handle OPEN_ADD_DIALOG', () => {
it("should handle OPEN_ADD_DIALOG", () => {
expect(
reducer(
{
......@@ -67,7 +67,7 @@ describe('addDialog reducer', () => {
)
})
it('should handle CLOSE_ADD_DIALOG', () => {
it("should handle CLOSE_ADD_DIALOG", () => {
expect(
reducer(
{
......@@ -107,7 +107,7 @@ describe('addDialog reducer', () => {
)
})
it('should handle UPDATE_ADD_DIALOG_NAME', () => {
it("should handle UPDATE_ADD_DIALOG_NAME", () => {
expect(
reducer(
{
......@@ -149,7 +149,7 @@ describe('addDialog reducer', () => {
)
})
it('should handle UPDATE_ADD_DIALOG_QUANTITY', () => {
it("should handle UPDATE_ADD_DIALOG_QUANTITY", () => {
expect(
reducer(
{
......
import { UPDATE_FILTER } from '../constants/ActionTypes'
import { UPDATE_FILTER } from "../constants/ActionTypes"
const filterTerm = (state = "", action) => {
switch (action.type) {
......
import reducer from './filterTerm'
import * as types from '../constants/ActionTypes'
import reducer from "./filterTerm"
import * as types from "../constants/ActionTypes"
describe('filterTerm reducer', () => {
it('should return the initial state', () => {
describe("filterTerm reducer", () => {
it("should return the initial state", () => {
expect(reducer(undefined, {})).toEqual("")
})
it('should handle UPDATE_FILTER', () => {
it("should handle UPDATE_FILTER", () => {
expect(
reducer([], {
type: types.UPDATE_FILTER,
filterTerm: 'Police Car'
filterTerm: "Police Car"
})
).toEqual(
'Police Car'
"Police Car"
)
expect(
reducer(
'Mac',
"Mac",
{
type: types.UPDATE_FILTER,
filterTerm: 'Macbook'
filterTerm: "Macbook"
}
)
).toEqual(
'Macbook'
"Macbook"
)
})
})
\ No newline at end of file
import { combineReducers } from 'redux'
import items from './items'
import filterTerm from './filterTerm'
import addDialog from './addDialog'
import { combineReducers } from "redux"
import items from "./items"
import filterTerm from "./filterTerm"
import addDialog from "./addDialog"
export default combineReducers({
items,
......
import { ITEM_DELETED, ITEMS_LOADED, ITEM_ADDED, ITEM_UPDATED } from '../constants/ActionTypes';
import { ITEM_DELETED, ITEMS_LOADED, ITEM_ADDED, ITEM_UPDATED } from "../constants/ActionTypes";
const items = (state = [], action) => {
switch (action.type) {
......
import reducer from './items'
import * as types from '../constants/ActionTypes'
import reducer from "./items"
import * as types from "../constants/ActionTypes"
describe('items reducer', () => {
it('should return the initial state', () => {
describe("items reducer", () => {
it("should return the initial state", () => {
expect(reducer(undefined, {})).toEqual([])
})
it('should handle ITEMS_LOADED', () => {
it("should handle ITEMS_LOADED", () => {
expect(
reducer([], {
type: types.ITEMS_LOADED,
......@@ -26,7 +26,7 @@ describe('items reducer', () => {
)
})
it('should handle ITEM_ADDED', () => {
it("should handle ITEM_ADDED", () => {
expect(
reducer([], {
type: types.ITEM_ADDED,
......@@ -50,7 +50,7 @@ describe('items reducer', () => {
)
})
it('should handle ITEM_DELETED', () => {
it("should handle ITEM_DELETED", () => {
expect(
reducer([], {
type: types.ITEM_DELETED,
......@@ -69,7 +69,7 @@ describe('items reducer', () => {
[{id: "ab25", name: "Couch", quantity: 3}]
)
})
it('should handle ITEM_UPDATED', () => {
it("should handle ITEM_UPDATED", () => {
expect(
reducer([], {
type: types.ITEM_UPDATED,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment