react-router-maa
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -249,7 +249,6 @@ import { __PRIVATES__, setCheckIfIsInitialisedFunction, pushTransitionAllowedCheckFunction, isTransitionAllowed } from '../../router/router.transition-middleware'; | ||
const transitionAllowedCheckFunction2 = () => true; | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(0); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
pushTransitionAllowedCheckFunction(transitionAllowedCheckFunction2); | ||
const pop2 = pushTransitionAllowedCheckFunction(transitionAllowedCheckFunction2); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
@@ -260,3 +259,30 @@ expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
const transitionAllowedCheckFunction3 = () => true; | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(1); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
const pop3 = pushTransitionAllowedCheckFunction(transitionAllowedCheckFunction3); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks()[0].checkFunc).toEqual(transitionAllowedCheckFunction); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(2); | ||
const transitionAllowedCheckFunction4 = () => true; | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(2); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
const pop4 = pushTransitionAllowedCheckFunction(transitionAllowedCheckFunction4); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks()[0].checkFunc).toEqual(transitionAllowedCheckFunction); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(3); | ||
pop3(); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks()[0].checkFunc).toEqual(transitionAllowedCheckFunction); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(2); | ||
expect(__PRIVATES__.getIsCheckingIfTransitionIsAllowed()).toEqual(true); | ||
resolveFunction(true); | ||
@@ -268,5 +294,17 @@ | ||
expect(res).toEqual(true); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); // 1 poped since route allowed and replaced by one from routerTransitionAllowedChecksPushFunctionsStack | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(2); // 1 poped since route allowed and 2 added from routerTransitionAllowedChecksPushFunctionsStack | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecksPushFunctionsStack().length).toEqual(0); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks()[0].checkFunc).toEqual(transitionAllowedCheckFunction2); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks()[1].checkFunc).toEqual(transitionAllowedCheckFunction4); | ||
pop3(); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(2); // nothing | ||
pop2(); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(1); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks()[0].checkFunc).toEqual(transitionAllowedCheckFunction4); | ||
pop4(); | ||
expect(__PRIVATES__.getRouterTransitionAllowedChecks().length).toEqual(0); | ||
done(); | ||
@@ -273,0 +311,0 @@ }) |
{ | ||
"name": "react-router-maa", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "state based react router linked to url through parseUrl and toUrl functions, has working route blocking control mechanisim, and async initialisation phase", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,3 @@ import { promisifyFunctionCall, sortedInsert } from "./router.util"; | ||
let obj = { checkFunc, popOnceRouteAllowed, priority, popCheckFunc }; | ||
const pushFunc = sortedInsert.bind(null, routerTransitionAllowedChecks, obj, priorityComareFunc); | ||
const popFunc = () => { | ||
@@ -18,7 +19,12 @@ for(let i = 0; i < routerTransitionAllowedChecks.length; i++) { | ||
routerTransitionAllowedChecks.splice(i, 1); | ||
break; | ||
return; | ||
} | ||
} | ||
for(let i = 0; i < routerTransitionAllowedChecksPushFunctionsStack.length; i++) { | ||
if(routerTransitionAllowedChecksPushFunctionsStack[i] === pushFunc) { | ||
routerTransitionAllowedChecksPushFunctionsStack.splice(i, 1); | ||
return; | ||
} | ||
} | ||
}; | ||
const pushFunc = sortedInsert.bind(null, routerTransitionAllowedChecks, obj, priorityComareFunc); | ||
if(isCheckingIfTransitionIsAllowed) { | ||
@@ -25,0 +31,0 @@ routerTransitionAllowedChecksPushFunctionsStack.push(pushFunc); |
Sorry, the diff of this file is too big to display
1112773
26005