Comparing version 0.20.4 to 0.20.5
@@ -191,2 +191,49 @@ 'use strict'; | ||
expect(secondLogic.selectors.capitalizedName(store.getState())).toBe('Derpy'); | ||
}); | ||
test('can get everything with *', function () { | ||
var store = (0, _redux.createStore)((0, _redux.combineReducers)({ | ||
scenes: (0, _store.keaReducer)('scenes') | ||
})); | ||
var firstLogic = (0, _kea.kea)({ | ||
path: function path() { | ||
return ['scenes', 'homepage', 'first']; | ||
}, | ||
actions: function actions(_ref10) { | ||
var constants = _ref10.constants; | ||
return { | ||
updateName: function updateName(name) { | ||
return { name: name }; | ||
} | ||
}; | ||
}, | ||
reducers: function reducers(_ref11) { | ||
var actions = _ref11.actions, | ||
constants = _ref11.constants; | ||
return { | ||
name: ['chirpy', _propTypes2.default.string, _defineProperty({}, actions.updateName, function (state, payload) { | ||
return payload.name; | ||
})] | ||
}; | ||
} | ||
}); | ||
var secondLogic = (0, _kea.kea)({ | ||
path: function path() { | ||
return ['scenes', 'homepage', 'second']; | ||
}, | ||
connect: { | ||
props: [firstLogic, ['name', '* as everything']] | ||
} | ||
}); | ||
expect(secondLogic._isKeaFunction).toBe(true); | ||
expect(secondLogic._isKeaSingleton).toBe(true); | ||
expect(secondLogic.path).toEqual(['scenes', 'homepage', 'second']); | ||
expect(Object.keys(secondLogic.actions)).toEqual([]); | ||
expect(Object.keys(secondLogic.selectors).sort()).toEqual(['everything', 'name', 'root']); | ||
store.dispatch(firstLogic.actions.updateName('derpy')); | ||
expect(secondLogic.selectors.everything(store.getState())).toEqual({ name: 'derpy' }); | ||
}); |
@@ -258,3 +258,3 @@ 'use strict'; | ||
if (typeof reducerTree[pathStart] === 'undefined') { | ||
console.error('[KEA-LOGIC] Path starting with "' + pathStart + '" is not connected to the reducer tree!', path); | ||
console.error('[KEA-LOGIC] Path starting with "' + pathStart + '" is not connected to the reducer tree! Make sure to call keaReducer() before any calls to kea() take place!', path); | ||
return; | ||
@@ -261,0 +261,0 @@ } |
{ | ||
"name": "kea", | ||
"version": "0.20.4", | ||
"version": "0.20.5", | ||
"description": "Smart front-end architecture", | ||
@@ -5,0 +5,0 @@ "author": "Marius Andra", |
@@ -174,1 +174,40 @@ /* global test, expect, beforeEach */ | ||
}) | ||
test('can get everything with *', () => { | ||
const store = createStore(combineReducers({ | ||
scenes: keaReducer('scenes') | ||
})) | ||
const firstLogic = kea({ | ||
path: () => ['scenes', 'homepage', 'first'], | ||
actions: ({ constants }) => ({ | ||
updateName: name => ({ name }) | ||
}), | ||
reducers: ({ actions, constants }) => ({ | ||
name: ['chirpy', PropTypes.string, { | ||
[actions.updateName]: (state, payload) => payload.name | ||
}] | ||
}) | ||
}) | ||
const secondLogic = kea({ | ||
path: () => ['scenes', 'homepage', 'second'], | ||
connect: { | ||
props: [ | ||
firstLogic, [ | ||
'name', | ||
'* as everything' | ||
] | ||
] | ||
} | ||
}) | ||
expect(secondLogic._isKeaFunction).toBe(true) | ||
expect(secondLogic._isKeaSingleton).toBe(true) | ||
expect(secondLogic.path).toEqual(['scenes', 'homepage', 'second']) | ||
expect(Object.keys(secondLogic.actions)).toEqual([]) | ||
expect(Object.keys(secondLogic.selectors).sort()).toEqual(['everything', 'name', 'root']) | ||
store.dispatch(firstLogic.actions.updateName('derpy')) | ||
expect(secondLogic.selectors.everything(store.getState())).toEqual({ name: 'derpy' }) | ||
}) |
@@ -127,3 +127,3 @@ import { call, take, cancel, fork } from 'redux-saga/effects' | ||
if (typeof reducerTree[pathStart] === 'undefined') { | ||
console.error(`[KEA-LOGIC] Path starting with "${pathStart}" is not connected to the reducer tree!`, path) | ||
console.error(`[KEA-LOGIC] Path starting with "${pathStart}" is not connected to the reducer tree! Make sure to call keaReducer() before any calls to kea() take place!`, path) | ||
return | ||
@@ -130,0 +130,0 @@ } |
331910
8400