Skip to content

Commit

Permalink
Lesson 5 : Redux: The Single Immutable State Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Grobim committed Jan 18, 2016
1 parent 45df427 commit ab6d9eb
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
React Redux Starter Kit
=======================
###### Once the app is running, click on 'Go to eggheadTutorial', for the steps of the tutorial

[![Join the chat at https://gitter.im/davezuko/react-redux-starter-kit](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/davezuko/react-redux-starter-kit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/davezuko/react-redux-starter-kit.svg?branch=master)](https://travis-ci.org/davezuko/react-redux-starter-kit?branch=master)
Expand Down
2 changes: 2 additions & 0 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { Route, IndexRoute, Redirect } from 'react-router';
// your current file is.
import CoreLayout from 'layouts/CoreLayout/CoreLayout';
import HomeView from 'views/HomeView/HomeView';
import EggHeadTutorial from 'views/EggHeadTutorial/EggHeadTutorial';
import NotFoundView from 'views/NotFoundView/NotFoundView';

export default (
<Route path='/' component={CoreLayout}>
<IndexRoute component={HomeView} />
<Route path='/404' component={NotFoundView} />
<Route path='/eggHeadTutorial' component={EggHeadTutorial} />
<Redirect from='*' to='/404' />
</Route>
);
64 changes: 64 additions & 0 deletions src/views/EggHeadTutorial/EggHeadTutorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react';
import expect from 'expect';
import { Link } from 'react-router';

export default class EggHeadTutorial extends React.Component {

constructor (props) {
super(props);

this.test();

console.log('Tests passed !');
}

test = () => {
const counter = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
};

expect(
counter(0, { type : 'INCREMENT' })
).toEqual(1);

expect(
counter(1, { type : 'INCREMENT' })
).toEqual(2);

expect(
counter(2, { type : 'DECREMENT' })
).toEqual(1);

expect(
counter(1, { type : 'DECREMENT' })
).toEqual(0);

expect(
counter(1, { type : 'SOMETHING_ELSE' })
).toEqual(1);

expect(
counter(undefined, {})
).toEqual(0);
};

render () {
return (
<div className='container text-center'>
<h1>This is the <a href='https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree' target='_blank'>tutorial</a></h1>
<p>Check out the console for assertions</p>
<p>The root of the tests are in views/EggHeadTutorial/EggHeadTutorial.js</p>
<hr />
<Link to='/'>Back To Home View</Link>
</div>
);
};

}

0 comments on commit ab6d9eb

Please sign in to comment.