Skip to content

Commit

Permalink
React interview test refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Witczak committed May 15, 2017
1 parent 882e554 commit ad93329
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# react-task

The minimal dev environment to enable live-editing React components.

## Usage

```
npm install
npm start
yarn install
yarn start
open http://localhost:3000
```

## Task

- Please add pagination support to the list when there are more than 2 entries
- Please add option to select sex of a friend male/female and display it
- Please add tests using your preferred testing tool (mocha, should.js ...)
- Please add tests using your preferred testing tool (jest, mocha, should.js ...)

## Objectives

Expand Down
17 changes: 13 additions & 4 deletions src/reducers/friendlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import * as types from '../constants/ActionTypes';
const initialState = {
friendsById: [
{
name: 'Theodore Roosevelt'
name: 'Theodore Roosevelt',
starred: true
},
{
name: 'Abraham Lincoln'
name: 'Abraham Lincoln',
starred: false
},
{
name: 'George Washington'
name: 'George Washington',
starred: false
}
]
};
Expand All @@ -32,7 +35,13 @@ export default function friends(state = initialState, action) {
friendsById: state.friendsById.filter((item, index) => index !== action.id)
};
case types.STAR_FRIEND:
return state;
let friends = [...state.friendsById];
let friend = friends.find((item, index) => index === action.id);
friend.starred = !friend.starred;
return {
...state,
friendsById: friends
};

default:
return state;
Expand Down

0 comments on commit ad93329

Please sign in to comment.