Skip to content

Commit

Permalink
Merge pull request #47 from swsnu/kichang/enhance_test
Browse files Browse the repository at this point in the history
enhance test
  • Loading branch information
yankee624 committed Nov 14, 2020
2 parents bf8ea26 + 255ffba commit 855f2fe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function App() {
<Route path = '/' exact component={MainPage}/>
<Route path = '/item/add' exact component = {AddItem}/>
<Route path = '/item/confirm' exact component={ItemConfirm}/>
<Route render={() => <h1>Not Found</h1>} />
{/* <Route render={() => <h1>Not Found</h1>} /> */}
</Switch>
</div>
</BrowserRouter>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import ReactDOM from 'react-dom';
import App from './App';
import { Provider } from 'react-redux';
import store from './store/store';
import { createMemoryHistory } from 'history';


it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Provider store={store}><App /></Provider>, div);
ReactDOM.unmountComponentAtNode(div);
});
});
1 change: 1 addition & 0 deletions frontend/src/containers/AddItem/AddItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class AddItem extends Component {
}
}
)
.catch(e => {});

/*
* Item is new to this user!
Expand Down
16 changes: 9 additions & 7 deletions frontend/src/containers/AddItem/AddItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ let result2 = {
container: null
}

let mockHistory = {push: jest.fn()};

describe('<AddItem />', () => {
it('should render without errors', () => {
const component = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
component.setState({ is_editing: true, currentResult: result })
component.update()

Expand All @@ -43,7 +45,7 @@ describe('<AddItem />', () => {
})

it('should render without error', () => {
const component2 = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component2 = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
component2.setState({ is_editing: true, currentResult: result2 })
component2.update()

Expand All @@ -67,7 +69,7 @@ describe('<AddItem />', () => {
})*/

it('should render without error4', async () => {
const component4 = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component4 = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
await component4.update()
expect(component4.find('button').find('#AddManuallyButton').length).toBe(1);
component4.find('button').find('#AddManuallyButton').simulate('click');
Expand Down Expand Up @@ -95,7 +97,7 @@ describe('<AddItem />', () => {
})

it('should render without error5', async () => {
const component = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
await component.update()
component.setState({ is_confirmed: false, currentResult: result })

Expand All @@ -121,7 +123,7 @@ describe('<AddItem />', () => {
})

it('should render without error5', async () => {
const component = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
await component.update()
component.setState({ is_confirmed: false, currentResult: result })

Expand All @@ -136,7 +138,7 @@ describe('<AddItem />', () => {
})

it('should turn off the webcam when clicking WEBCAM ON/OFF', async () => {
const component = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
await component.update()
component.setState({ is_confirmed: false, currentResult: result })
await component.update()
Expand All @@ -153,7 +155,7 @@ describe('<AddItem />', () => {
})

it('should work with setExpirationDate function', async () => {
const component = mount(<AddItem location={{state: {container: "fridge"}}}></AddItem>);
const component = mount(<AddItem history={mockHistory} location={{state: {container: "fridge"}}}></AddItem>);
await component.update()
component.setState({ is_confirmed: false, currentResult: result })
await component.update()
Expand Down

0 comments on commit 855f2fe

Please sign in to comment.