Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('creates a cache entry for each exact/strict pair', () => {
// true/false and false/true will collide when adding booleans
const trueFalse = matchPath('/one/two', {
path: '/one/two/',
exact: true,
strict: false
});
const falseTrue = matchPath('/one/two', {
path: '/one/two/',
exact: false,
strict: true
});
expect(!!trueFalse).toBe(true);
expect(!!falseTrue).toBe(false);
});
});
it('creates a cache entry for each exact/strict pair', () => {
// true/false and false/true will collide when adding booleans
const trueFalse = matchPath('/one/two', {
path: '/one/two/',
exact: true,
strict: false
});
const falseTrue = matchPath('/one/two', {
path: '/one/two/',
exact: false,
strict: true
});
expect(!!trueFalse).toBe(true);
expect(!!falseTrue).toBe(false);
});
});
asyncBefore={url => {
// console.log('Async before...')
return doAllAsyncBefore(match(routes, url));
}}
>
function didEnter() {
requestAnimationFrame(() => {
expect(innerHTML(container.innerHTML)).toBe(
innerHTML("<div>Page No Async</div>")
);
done();
});
}
const routes = (
);
const renderProps = match(routes, "/");
doAllAsyncBefore(renderProps).then(() => {
// Then render
render(routes, container);
});
});
const routes = (
);
// Need to prime the route props with data on first render. With SSR this should be done by hydration
// so makes sense not to perform automagically in router.
const renderProps = match(routes, "/");
doAllAsyncBefore(renderProps).then(() => {
// Then render
render(routes, container);
});
});
>
gh3orus
{/* */}
{/*
TODO: Uncomment when feeling like implementing Discord auth
*/}
);
}
}
export default withRouter(NavBar);
routes.some(route => {
const match = route.path
? matchPath(pathname, route)
: branch.length
? branch[branch.length - 1].match // use parent match
: computeMatch(pathname); // use default "root" match
if (match) {
branch.push({ route, match });
if (route.routes) {
matchRoutes(route.routes, pathname, branch);
}
}
return match;
});
import { Router, matchPath } from "inferno-router";
// ensure we're using the exact code for default root match
const { computeMatch } = Router.prototype;
const matchRoutes = (routes, pathname, /*not public API*/ branch = []) => {
routes.some(route => {
const match = route.path
? matchPath(pathname, route)
: branch.length
? branch[branch.length - 1].match // use parent match
: computeMatch(pathname); // use default "root" match
if (match) {
branch.push({ route, match });
if (route.routes) {
matchRoutes(route.routes, pathname, branch);
}
}
it('provides the parent match as a prop to the wrapped component', () => {
let parentMatch;
const PropsChecker = withRouter(props => {
expect(props.match).toEqual(parentMatch);
return null;
});
render(
{
parentMatch = match;
return ;
}}
/>
,
node
);
it('exposes the instance of the wrapped component via wrappedComponentRef', () => {
class WrappedComponent extends Component {
render() {
return null;
}
}
const TestComponent = withRouter(WrappedComponent);
let ref;
render(
(ref = r)} />} />
,
node
);
expect(ref instanceof Component).toBe(true);
});