11import Immutable , { Map , List , is } from 'immutable'
22import { Reactor , Store } from '../src/main'
3+ import { getOption } from '../src/reactor/fns'
34import { toImmutable } from '../src/immutable-helpers'
5+ import { PROD_OPTIONS , DEBUG_OPTIONS } from '../src/reactor/records'
46import logging from '../src/logging'
57
68describe ( 'Reactor' , ( ) => {
@@ -9,6 +11,49 @@ describe('Reactor', () => {
911 expect ( reactor instanceof Reactor ) . toBe ( true )
1012 } )
1113
14+ describe ( 'debug and options flags' , ( ) => {
15+ it ( 'should create a reactor with PROD_OPTIONS' , ( ) => {
16+ var reactor = new Reactor ( )
17+ expect ( reactor . reactorState . get ( 'debug' ) ) . toBe ( false )
18+ expect ( is ( reactor . reactorState . get ( 'options' ) , PROD_OPTIONS ) ) . toBe ( true )
19+ } )
20+ it ( 'should create a reactor with DEBUG_OPTIONS' , ( ) => {
21+ var reactor = new Reactor ( {
22+ debug : true ,
23+ } )
24+ expect ( reactor . reactorState . get ( 'debug' ) ) . toBe ( true )
25+ expect ( is ( reactor . reactorState . get ( 'options' ) , DEBUG_OPTIONS ) ) . toBe ( true )
26+ } )
27+ it ( 'should override PROD options' , ( ) => {
28+ var reactor = new Reactor ( {
29+ options : {
30+ logDispatches : true ,
31+ }
32+ } )
33+ expect ( getOption ( reactor . reactorState , 'logDispatches' ) ) . toBe ( true )
34+ expect ( getOption ( reactor . reactorState , 'logAppState' ) ) . toBe ( false )
35+ expect ( getOption ( reactor . reactorState , 'logDirtyStores' ) ) . toBe ( false )
36+ expect ( getOption ( reactor . reactorState , 'allowUndefinedDispatch' ) ) . toBe ( true )
37+ expect ( getOption ( reactor . reactorState , 'allowNonImmutableStores' ) ) . toBe ( true )
38+ expect ( getOption ( reactor . reactorState , 'allowDispatchInDispatch' ) ) . toBe ( true )
39+ } )
40+ it ( 'should override DEBUG options' , ( ) => {
41+ var reactor = new Reactor ( {
42+ debug : true ,
43+ options : {
44+ logDispatches : false ,
45+ allowDispatchInDispatch : true ,
46+ }
47+ } )
48+ expect ( getOption ( reactor . reactorState , 'logDispatches' ) ) . toBe ( false )
49+ expect ( getOption ( reactor . reactorState , 'logAppState' ) ) . toBe ( true )
50+ expect ( getOption ( reactor . reactorState , 'logDirtyStores' ) ) . toBe ( true )
51+ expect ( getOption ( reactor . reactorState , 'allowUndefinedDispatch' ) ) . toBe ( false )
52+ expect ( getOption ( reactor . reactorState , 'allowNonImmutableStores' ) ) . toBe ( false )
53+ expect ( getOption ( reactor . reactorState , 'allowDispatchInDispatch' ) ) . toBe ( true )
54+ } )
55+ } )
56+
1257 describe ( 'Reactor with no initial state' , ( ) => {
1358 var checkoutActions
1459 var reactor
0 commit comments