From 8ffad110a07c57469df8c27c6fbff4785fbc2170 Mon Sep 17 00:00:00 2001 From: Chris Gubbels Date: Wed, 25 Oct 2023 15:52:36 -0600 Subject: [PATCH 1/2] updating test --- router.js | 4 ++-- test/router-spec.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/router.js b/router.js index bc7c5da..d64cfdd 100644 --- a/router.js +++ b/router.js @@ -20,7 +20,7 @@ * @property {string} id * @property {string} tagName * @property {string} path - * @property {Array=} parameters + * @property {Array=} params * @property {boolean=} authenticated * @property {Array=} subRoutes */ @@ -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)); diff --git a/test/router-spec.js b/test/router-spec.js index fb8bf5f..c58ecbb 100644 --- a/test/router-spec.js +++ b/test/router-spec.js @@ -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', @@ -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]); - }) + }); + }); }); From 93f773c86e348538b5b5fddc2a89aff5fda437b3 Mon Sep 17 00:00:00 2001 From: Chris Gubbels Date: Wed, 25 Oct 2023 15:53:36 -0600 Subject: [PATCH 2/2] v3.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8bfc787..ede76e6 100644 --- a/package.json +++ b/package.json @@ -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",