Skip to content

Commit

Permalink
DEV routerTypes
Browse files Browse the repository at this point in the history
* add optin routing
* apply error routing towards optin
  • Loading branch information
cdcabrera committed Apr 7, 2020
1 parent 5192c69 commit 6f40fdd
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ exports[`Router Component should render a basic component: basic 1`] = `
/>
<Route
exact={true}
key="/tour"
path="/tour"
key="/optin"
path="/optin"
render={[Function]}
/>
<Redirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ exports[`RouterHelpers should return a generated baseName using a beta path pref

exports[`RouterHelpers should return a generated baseName using a beta path prefix: beta app lorem route name 1`] = `"/beta/appName"`;

exports[`RouterHelpers should return an error route: error route 1`] = `
Object {
"activateOnError": true,
"component": Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"displayName": "Connect(OptinView)",
"type": [Function],
},
"disabled": false,
"exact": true,
"id": "optin",
"render": true,
"to": "/optin",
}
`;

exports[`RouterHelpers should return navigation and route details that align to location: detail: match specific path navigation 1`] = `
Object {
"nav": Object {
Expand Down Expand Up @@ -186,7 +204,6 @@ Object {
"nav": Object {},
"navRoute": Object {},
"route": Object {
"activateOnError": true,
"component": Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ Array [
]
`;

exports[`RouterTypes should return specific properties: platformRedirect 1`] = `"/?not_entitled=subscriptions"`;
exports[`RouterTypes should return specific properties: platformLandingRedirect 1`] = `"/"`;

exports[`RouterTypes should return specific properties: platformModalRedirect 1`] = `"/?not_entitled=subscriptions"`;

exports[`RouterTypes should return specific properties: routes 1`] = `
Array [
Expand Down Expand Up @@ -91,7 +93,6 @@ Array [
"to": "/openshift-sw",
},
Object {
"activateOnError": true,
"component": Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
Expand All @@ -106,18 +107,19 @@ Array [
"to": "/soon",
},
Object {
"activateOnError": true,
"component": Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"displayName": "Connect(TourView)",
"displayName": "Connect(OptinView)",
"type": [Function],
},
"disabled": false,
"exact": true,
"id": "tour",
"id": "optin",
"render": true,
"to": "/tour",
"to": "/optin",
},
]
`;
14 changes: 13 additions & 1 deletion src/components/router/__tests__/routerHelpers.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { baseName, dynamicBaseName, getNavigationDetail, getRouteDetail, getNavRouteDetail } from '../routerHelpers';
import {
baseName,
dynamicBaseName,
getErrorRoute,
getNavigationDetail,
getRouteDetail,
getNavRouteDetail
} from '../routerHelpers';

describe('RouterHelpers', () => {
it('should return specific properties', () => {
expect(baseName).toBeDefined();
expect(dynamicBaseName).toBeDefined();
expect(getErrorRoute).toBeDefined();
expect(getNavigationDetail).toBeDefined();
expect(getRouteDetail).toBeDefined();
expect(getNavRouteDetail).toBeDefined();
Expand Down Expand Up @@ -61,6 +69,10 @@ describe('RouterHelpers', () => {
).toMatchSnapshot('beta app lorem route name');
});

it('should return an error route', () => {
expect(getErrorRoute).toMatchSnapshot('error route');
});

it('should return navigation and route details that align to location', () => {
expect({
nav: getNavigationDetail({ id: 'soon' }),
Expand Down
5 changes: 3 additions & 2 deletions src/components/router/__tests__/routerTypes.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { appName, navigation, platformRedirect, routes } from '../routerTypes';
import { appName, navigation, platformLandingRedirect, platformModalRedirect, routes } from '../routerTypes';

describe('RouterTypes', () => {
it('should return specific properties', () => {
expect(appName).toMatchSnapshot('appName');
expect(navigation).toMatchSnapshot('navigation');
expect(platformRedirect).toMatchSnapshot('platformRedirect');
expect(platformLandingRedirect).toMatchSnapshot('platformLandingRedirect');
expect(platformModalRedirect).toMatchSnapshot('platformModalRedirect');
expect(routes).toMatchSnapshot('routes');
});
});
31 changes: 24 additions & 7 deletions src/components/router/routerTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path';
import { helpers } from '../../common/helpers';
import OpenshiftView from '../openshiftView/openshiftView';
import OptinView from '../optinView/optinView';
import RhelView from '../rhelView/rhelView';
import TourView from '../tourView/tourView';
import { RHSM_API_PATH_ID_TYPES } from '../../types/rhsmApiTypes';
Expand All @@ -17,7 +18,14 @@ const appName = helpers.UI_NAME;
*
* @returns {Array}
*/
const platformRedirect = path.join(helpers.UI_DEPLOY_PATH_PREFIX, '/?not_entitled=subscriptions');
const platformLandingRedirect = path.join(helpers.UI_DEPLOY_PATH_PREFIX, '/');

/**
* Return a string that describes a platform redirect.
*
* @returns {Array}
*/
const platformModalRedirect = path.join(helpers.UI_DEPLOY_PATH_PREFIX, '/?not_entitled=subscriptions');

/**
* Return array of objects that describes routing.
Expand Down Expand Up @@ -55,15 +63,15 @@ const routes = [
component: TourView,
exact: true,
render: true,
activateOnError: true,
disabled: helpers.UI_DISABLED
},
{
id: 'tour',
to: '/tour',
component: TourView,
id: 'optin',
to: '/optin',
component: OptinView,
exact: true,
render: true,
activateOnError: true,
disabled: helpers.UI_DISABLED
}
];
Expand Down Expand Up @@ -116,8 +124,17 @@ const navigation = [
const routerTypes = {
appName,
navigation,
platformRedirect,
platformLandingRedirect,
platformModalRedirect,
routes
};

export { routerTypes as default, routerTypes, appName, navigation, platformRedirect, routes };
export {
routerTypes as default,
routerTypes,
appName,
navigation,
platformLandingRedirect,
platformModalRedirect,
routes
};

0 comments on commit 6f40fdd

Please sign in to comment.