@cicada/render
Advanced tools
Comparing version 1.1.20 to 1.1.21
@@ -41,2 +41,10 @@ 'use strict'; | ||
var _business = require('../../background/utility/business'); | ||
var businessBackground = _interopRequireWildcard(_business); | ||
var _mapBackgroundToState = require('../../background/job/mapBackgroundToState'); | ||
var mapBackgroundToStateJob = _interopRequireWildcard(_mapBackgroundToState); | ||
var _stateTree = require('../../background/utility/stateTree'); | ||
@@ -393,2 +401,44 @@ | ||
expect(fromCalled).toBe(1); | ||
}); | ||
it('fragment with business', function () { | ||
var fragment = { | ||
config: { | ||
type: 'Input', | ||
bind: 'input', | ||
mapBackgroundToState: function mapBackgroundToState(_ref10) { | ||
var business = _ref10.business; | ||
return { | ||
value: business.get('value') || 'default' | ||
}; | ||
} | ||
}, | ||
didMount: function didMount(_ref11) { | ||
var business = _ref11.business; | ||
business.set('value', 'newValue'); | ||
} | ||
}; | ||
var Input = (0, _connect2.default)(InputComponent, 'Input'); | ||
var appliedCreateStateTree = (0, _applyStateTreeSubscriber2.default)(_createStateTree2.default); | ||
var FragmentInput = (0, _connect2.default)((0, _convertFragment2.default)(fragment, appliedCreateStateTree, _createAppearance2.default, _createBackground2.default, { utilities: { stateTree: stateTreeUtility, business: businessBackground }, jobs: { mapBackgroundToState: mapBackgroundToStateJob } }), 'FragmentInput'); | ||
var pageConfig = { | ||
type: 'FragmentInput', | ||
bind: 'frag' | ||
}; | ||
var stateTree = appliedCreateStateTree(); | ||
var bgInstance = (0, _createBackground2.default)({ utilities: { stateTree: stateTreeUtility, business: businessBackground }, jobs: { mapBackgroundToState: mapBackgroundToStateJob } }, stateTree, (0, _createAppearance2.default)()); | ||
var container = (0, _enzyme.mount)(_react2.default.createElement(_Render2.default, { | ||
config: pageConfig, | ||
components: { Input: Input, FragmentInput: FragmentInput }, | ||
stateTree: stateTree, | ||
background: bgInstance | ||
})); | ||
expect(container.html()).toEqual('<input value="newValue">'); | ||
}); |
@@ -43,3 +43,3 @@ 'use strict'; | ||
stateIdToMapFns[stateId] = mapBackgroundToState; | ||
stateIdToMapFns[stateId] = typeof mapBackgroundToState === 'function' ? [mapBackgroundToState] : mapBackgroundToState; | ||
return function () { | ||
@@ -81,3 +81,3 @@ delete stateIdToMapFns[stateId]; | ||
return mapBackgroundToState !== undefined && Array.isArray(mapBackgroundToState) && mapBackgroundToState.length !== 0; | ||
return mapBackgroundToState !== undefined && (typeof mapBackgroundToState === 'function' || Array.isArray(mapBackgroundToState) && mapBackgroundToState.length !== 0); | ||
} |
@@ -24,5 +24,4 @@ 'use strict'; | ||
return function unsubscribe() { | ||
subscribers.splice(subscribers.findIndex(function (subscriber) { | ||
return subscriber !== fn; | ||
}), 1); | ||
var index = subscribers.indexOf(fn); | ||
if (index !== -1) subscribers.splice(index, 1); | ||
}; | ||
@@ -29,0 +28,0 @@ }, |
{ | ||
"name": "@cicada/render", | ||
"version": "1.1.20", | ||
"version": "1.1.21", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
402445
9750