mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-14 05:14:28 -08:00
redux example WIP
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { combineReducers } from 'redux'
|
||||
import todos from './todos'
|
||||
import visibilityFilter from './visibilityFilter'
|
||||
import todos from './todos.js'
|
||||
import visibilityFilter from './visibilityFilter.js'
|
||||
|
||||
export default combineReducers({
|
||||
export default Redux.combineReducers({
|
||||
todos,
|
||||
visibilityFilter
|
||||
})
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
import todos from './todos'
|
||||
|
||||
describe('todos reducer', () => {
|
||||
it('should handle initial state', () => {
|
||||
expect(
|
||||
todos(undefined, {})
|
||||
).toEqual([])
|
||||
})
|
||||
|
||||
it('should handle ADD_TODO', () => {
|
||||
expect(
|
||||
todos([], {
|
||||
type: 'ADD_TODO',
|
||||
text: 'Run the tests',
|
||||
id: 0
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: false,
|
||||
id: 0
|
||||
}
|
||||
])
|
||||
|
||||
expect(
|
||||
todos([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: false,
|
||||
id: 0
|
||||
}
|
||||
], {
|
||||
type: 'ADD_TODO',
|
||||
text: 'Use Redux',
|
||||
id: 1
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: false,
|
||||
id: 0
|
||||
}, {
|
||||
text: 'Use Redux',
|
||||
completed: false,
|
||||
id: 1
|
||||
}
|
||||
])
|
||||
|
||||
expect(
|
||||
todos([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: false,
|
||||
id: 0
|
||||
}, {
|
||||
text: 'Use Redux',
|
||||
completed: false,
|
||||
id: 1
|
||||
}
|
||||
], {
|
||||
type: 'ADD_TODO',
|
||||
text: 'Fix the tests',
|
||||
id: 2
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: false,
|
||||
id: 0
|
||||
}, {
|
||||
text: 'Use Redux',
|
||||
completed: false,
|
||||
id: 1
|
||||
}, {
|
||||
text: 'Fix the tests',
|
||||
completed: false,
|
||||
id: 2
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('should handle TOGGLE_TODO', () => {
|
||||
expect(
|
||||
todos([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: false,
|
||||
id: 1
|
||||
}, {
|
||||
text: 'Use Redux',
|
||||
completed: false,
|
||||
id: 0
|
||||
}
|
||||
], {
|
||||
type: 'TOGGLE_TODO',
|
||||
id: 1
|
||||
})
|
||||
).toEqual([
|
||||
{
|
||||
text: 'Run the tests',
|
||||
completed: true,
|
||||
id: 1
|
||||
}, {
|
||||
text: 'Use Redux',
|
||||
completed: false,
|
||||
id: 0
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VisibilityFilters } from '../actions'
|
||||
import { VisibilityFilters } from '../actions/index.js'
|
||||
|
||||
const visibilityFilter = (state = VisibilityFilters.SHOW_ALL, action) => {
|
||||
switch (action.type) {
|
||||
|
||||
Reference in New Issue
Block a user