@@ -3,7 +3,8 @@ import * as actions from '../../src/redux/actions';
33import * as module from '../../src/listener' ;
44import { createStore } from 'redux' ;
55import sinon from 'sinon' ;
6- import jsdom from 'jsdom' ;
6+ import * as strape from '../../src/engines/strape' ;
7+ import { EXIT_STRATEGY_MIRROR , EXIT_STRATEGY_START } from '../../src/constants' ;
78
89describe ( 'redux/actions.js' , ( ) => {
910 describe ( 'clone' , ( ) => {
@@ -135,48 +136,26 @@ describe('redux/actions.js', () => {
135136 callback . should . have . been . calledOnce ;
136137 } ) ) ;
137138
138- it ( 'should call dispatcher when callback is a string and no strategy' , sinon . test ( function ( ) {
139- const store = createStore ( ( state = {
140- '@@keys' : {
141- binderId : { active : false , selectedId : 1 , marginLeft : 0 } ,
142- } ,
143- } ) => state ) ;
144- module . _init ( { store : store } ) ; // init globalStore
145- this . mock ( module . globalStore )
146- . expects ( 'dispatch' )
139+ it ( 'should call findMirrorExitId when strategy is mirror' , sinon . test ( function ( ) {
140+ this . mock ( strape )
141+ . expects ( 'findMirrorExitId' )
147142 . once ( ) ;
148- actions . exitBinder ( null , 'binderId ' , 'nextEl1 ' ) ;
143+ actions . exitBinder ( EXIT_STRATEGY_MIRROR , 'strape ' , 'ID ' ) ;
149144 } ) ) ;
150145
151- it ( 'should call dispatcher when callback is a string with mirror stategy' ,
152- sinon . test ( function ( ) {
153- const store = createStore ( ( state = {
154- '@@keys' : {
155- binderId : { active : false , selectedId : 1 , marginLeft : 0 } ,
156- } ,
157- } ) => state ) ;
158- module . _init ( { store : store } ) ; // init globalStore
159- this . mock ( module . globalStore )
160- . expects ( 'dispatch' )
161- . once ( ) ;
162- actions . exitBinder ( 'mirror' , 'binderId' , 'nextEl1' ) ;
163- } ) ) ;
164-
165- /* eslint no-native-reassign: 0 */
166- it ( 'should' , sinon . test ( function ( ) {
167- document = jsdom . jsdom ( '<div id="wrapper"><ul><li id="1"></li></ul></div>' +
168- '<div id="binderId"><ul><li></li></ul></div>' ) ;
169- const store = createStore ( ( state = {
170- '@@keys' : {
171- binderId : { active : false , selectedId : 1 , marginLeft : 0 } ,
172- } ,
173- } ) => state ) ;
174- module . _init ( { store : store } ) ; // init globalStore
175- this . mock ( module . globalStore )
176- . expects ( 'dispatch' )
146+ it ( 'should call findStartExitId when strategy is start' , sinon . test ( function ( ) {
147+ this . mock ( strape )
148+ . expects ( 'findStartExitId' )
177149 . once ( ) ;
178- actions . exitBinder ( 'mirror' , 'binderId' , 'nextEl1' ) ;
179- document = null ;
150+ actions . exitBinder ( EXIT_STRATEGY_START , 'strape' , 'ID' ) ;
151+ } ) ) ;
152+
153+ it ( 'should not call any engine when other strategy' , sinon . test ( function ( ) {
154+ const mirrorSpy = this . spy ( strape , 'findMirrorExitId' ) ;
155+ const startSpy = this . spy ( strape , 'findStartExitId' ) ;
156+ actions . exitBinder ( 'FUCKING_STRATEGY' , 'strape' , 'ID' ) ;
157+ mirrorSpy . should . have . been . not . called ;
158+ startSpy . should . have . been . not . called ;
180159 } ) ) ;
181160 } ) ;
182161} ) ;
0 commit comments