@@ -230,6 +230,78 @@ describe('renderToString$', function() {
230230 ) ;
231231 } ) ;
232232
233+ it ( 'should prevent infinite loops' , done => {
234+ const element = React . createElement ( createContainer (
235+ {
236+ actions : [ 'catActions' ] ,
237+ store : 'catStore' ,
238+ fetchAction : 'catActions.doAction' ,
239+ getPayload : ( ) => ( { } )
240+ } ,
241+ createClass ( {
242+ displayName : 'Test' ,
243+ propTypes : {
244+ catActions : React . PropTypes . object
245+ } ,
246+ componentWillMount ( ) {
247+ this . props . catActions . doThis ( ) ;
248+ } ,
249+
250+ render ( ) {
251+ return React . createElement ( 'h1' , null , 'hello world' ) ;
252+ }
253+ } )
254+ ) ) ;
255+
256+ const CatActions = Actions ( {
257+ refs : { displayName : 'catActions' } ,
258+ doAction ( ) {
259+ return Observable . just ( { set : { foo : 'baz' } } ) . delay ( 500 ) ;
260+ } ,
261+ doThis ( ) {
262+ return { set : { qux : 'quo' } } ;
263+ }
264+ } ) ;
265+
266+ const CatStore = Store ( {
267+ refs : {
268+ value : { foo : 'bar' } ,
269+ displayName : 'CatStore'
270+ } ,
271+ init ( { instance : store , args : [ cat ] } ) {
272+ const actions = cat . getActions ( 'catActions' ) ;
273+ store . register ( actions . doAction ) ;
274+ store . register ( actions . doThis ) ;
275+ }
276+ } ) ;
277+
278+
279+ const cat = Cat ( ) ( ) ;
280+
281+ cat . register ( CatActions ) ;
282+ cat . register ( CatStore , null , cat ) ;
283+
284+ renderToString$ ( cat , element )
285+ . flatMap (
286+ dehydrate ( cat ) ,
287+ )
288+ . doOnNext ( ( { CatStore } ) => {
289+ assert . equal (
290+ CatStore . foo ,
291+ 'baz' ,
292+ 'foo did not equal baz'
293+ ) ;
294+
295+ assert . isNotOk ( CatStore . qux ) ;
296+ } )
297+ . subscribe (
298+ ( ) => { } ,
299+ done ,
300+ done
301+ ) ;
302+
303+ } ) ;
304+
233305 it ( 'should error on fetch errors' , ( done ) => {
234306 renderToString$ ( cat , 'not the momma' )
235307 . subscribe (
0 commit comments