Skip to content

Commit

Permalink
Merge pull request #68 from Banno/readme-fix
Browse files Browse the repository at this point in the history
updating test
  • Loading branch information
jrobinson01 authored Oct 26, 2023
2 parents e1426e9 + 93f773c commit 1ee4787
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jack-henry/web-component-router",
"version": "3.0.1",
"version": "3.0.2",
"description": "Web Components Router",
"main": "router.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @property {string} id
* @property {string} tagName
* @property {string} path
* @property {Array<string>=} parameters
* @property {Array<string>=} params
* @property {boolean=} authenticated
* @property {Array<RouteConfig>=} subRoutes
*/
Expand Down Expand Up @@ -82,7 +82,7 @@ class Router {
/** @param {!RouteConfig} routeConfig */
buildRouteTree(routeConfig) {
const authenticated = [true, false].includes(routeConfig.authenticated) ? routeConfig.authenticated : true;
const node = new RouteTreeNode(new RouteData(routeConfig.id, routeConfig.tagName, routeConfig.path, routeConfig.parameters || [], authenticated));
const node = new RouteTreeNode(new RouteData(routeConfig.id, routeConfig.tagName, routeConfig.path, routeConfig.params || [], authenticated));
if (routeConfig.subRoutes) {
routeConfig.subRoutes.forEach(route => {
node.addChild(this.buildRouteTree(route));
Expand Down
8 changes: 7 additions & 1 deletion test/router-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ describe('Router', () => {
tagName: 'APP-USER-PAGE',
path: '/users/:userId([0-9]{1,6})',
requiresAuthentication: true,
params: ['userId'],
}, {
id: 'app-user-account',
tagName: 'APP-ACCOUNT-PAGE',
path: '/users/:userId([0-9]{1,6})/accounts/:accountId([0-9]{1,6})',
requiresAuthentication: true,
params: ['userId', 'accountId'],
}, {
id: 'app-about',
tagName: 'APP-ABOUT',
Expand All @@ -130,9 +132,13 @@ describe('Router', () => {
expect(subRoutes.length).toBe(3);
subRoutes.forEach((route, index) => {
const data = route.getValue();
if (testSubRouteData[index].params) {
expect(Object.keys(data.attributes)).toEqual(testSubRouteData[index].params);
}
['id', 'tagName', 'path', 'requiresAuthentication'].forEach((prop) => {
expect(data[prop]).toBe(testSubRouteData[index][prop]);
})
});

});
});

Expand Down

0 comments on commit 1ee4787

Please sign in to comment.