26 |
27 | ,
28 | rootElement
29 | );
30 | }
31 |
32 |
33 | if (module.hot) {
34 | module.hot.accept('./views/app', () => {
35 | render(require('./views/app').default);
36 | })
37 | }
38 |
39 |
40 | registerServiceWorker();
41 |
42 |
43 | initAuth(store.dispatch)
44 | .then(() => render(App))
45 | .catch(error => console.error(error));
46 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Richard Park
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/tasks/selectors.spec.js:
--------------------------------------------------------------------------------
1 | import { List } from 'immutable';
2 | import { TasksState } from './reducer';
3 | import { getVisibleTasks } from './selectors';
4 | import { Task } from './task';
5 |
6 |
7 | describe('Tasks selectors', () => {
8 | let tasks;
9 |
10 | beforeEach(() => {
11 | tasks = new TasksState({
12 | list: new List([
13 | new Task({completed: false, title: 'task-1'}),
14 | new Task({completed: true, title: 'task-2'})
15 | ])
16 | });
17 | });
18 |
19 |
20 | describe('getVisibleTasks()', () => {
21 | it('should return list of all tasks', () => {
22 | let taskList = getVisibleTasks({tasks});
23 | expect(taskList.size).toBe(2);
24 | });
25 |
26 | it('should return list of active (incomplete) tasks', () => {
27 | tasks = tasks.set('filter', 'active');
28 | let taskList = getVisibleTasks({tasks});
29 |
30 | expect(taskList.size).toBe(1);
31 | expect(taskList.get(0).title).toBe('task-1');
32 | });
33 |
34 | it('should return list of completed tasks', () => {
35 | tasks = tasks.set('filter', 'completed');
36 | let taskList = getVisibleTasks({tasks});
37 |
38 | expect(taskList.size).toBe(1);
39 | expect(taskList.get(0).title).toBe('task-2');
40 | });
41 | });
42 | });
43 |
--------------------------------------------------------------------------------
/src/views/app/app.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import { connect } from 'react-redux';
4 | import { withRouter } from 'react-router-dom';
5 |
6 | import { authActions, getAuth } from 'src/auth';
7 | import Header from '../components/header';
8 | import RequireAuthRoute from '../components/require-auth-route';
9 | import RequireUnauthRoute from '../components/require-unauth-route';
10 | import SignInPage from '../pages/sign-in';
11 | import TasksPage from '../pages/tasks';
12 |
13 |
14 | const App = ({authenticated, signOut}) => (
15 |