-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1f99c0
commit e66e056
Showing
13 changed files
with
310 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import * as actions from './actions'; | ||
import { REQUEST_ROBOTS_PENDING } from './constants'; | ||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
describe("Fetch robots action PENDING", () => { | ||
it("should create a Pending action on request Robots", () => { | ||
const store = mockStore({}); | ||
return store.dispatch(actions.requestRobots()) | ||
.then(() => { | ||
const action = store.getActions(); | ||
expect(action[0]).toEqual({ type: REQUEST_ROBOTS_PENDING }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import MainPage from './MainPage'; | ||
|
||
describe('MainPage component', () => { | ||
it('renders MainPage without crashing', () => { | ||
const mockProps = { | ||
onRequestRobots: jest.fn(), | ||
robots: [], | ||
searchField: '', | ||
isPending: false | ||
}; | ||
const wrapper = shallow(<MainPage {...mockProps} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('filters robots correctly', () => { | ||
const mockProps = { | ||
onRequestRobots: jest.fn(), | ||
robots: [{ | ||
id: 3, | ||
name: 'John', | ||
email: '[email protected]' | ||
}], | ||
searchField: 'j', | ||
isPending: false | ||
}; | ||
const wrapper = shallow(<MainPage {...mockProps} />); | ||
expect(wrapper.instance().filterRobots()).toEqual([{ | ||
id: 3, | ||
name: 'John', | ||
email: '[email protected]' | ||
}]); | ||
}); | ||
|
||
it('filters robots correctly with different search term', () => { | ||
const mockProps = { | ||
onRequestRobots: jest.fn(), | ||
robots: [{ | ||
id: 3, | ||
name: 'John', | ||
email: '[email protected]' | ||
}], | ||
searchField: 'a', | ||
isPending: false | ||
}; | ||
const wrapper = shallow(<MainPage {...mockProps} />); | ||
expect(wrapper.instance().filterRobots()).toEqual([]); | ||
}); | ||
}); |
Oops, something went wrong.