From 77d5ef82bd19f8b4c73e916bd40e65457eea6092 Mon Sep 17 00:00:00 2001 From: John Robinson Date: Mon, 30 Oct 2023 09:29:20 -0400 Subject: [PATCH 1/4] fix: make router.go async --- router.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/router.js b/router.js index d64cfdd..13026e9 100644 --- a/router.js +++ b/router.js @@ -115,10 +115,11 @@ class Router { * Navigate to the specified route * @param {string} path * @param {Object=} params Values to use for named & query parameters + * @returns {!Promise} */ - go(path, params) { + async go(path, params) { path = this.url(path, params); - this.page.show(path); + return this.page.show(path); } /** From 6983b919ef559bd39a9a02de0e8277545e34186a Mon Sep 17 00:00:00 2001 From: John Robinson Date: Mon, 30 Oct 2023 09:33:18 -0400 Subject: [PATCH 2/4] chore: version -> 3.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ede76e6..4f849bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jack-henry/web-component-router", - "version": "3.0.2", + "version": "3.0.3", "description": "Web Components Router", "main": "router.js", "type": "module", From 3ec3983567d4945f7a667a96d2b993cd6c58f93d Mon Sep 17 00:00:00 2001 From: John Robinson Date: Mon, 30 Oct 2023 10:00:14 -0400 Subject: [PATCH 3/4] test: add async router.go test --- test/router-spec.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/router-spec.js b/test/router-spec.js index c58ecbb..2245a09 100644 --- a/test/router-spec.js +++ b/test/router-spec.js @@ -206,7 +206,8 @@ describe('Router', () => { describe('go()', () => { beforeEach(() => { - spyOn(router.page, JSCompiler_renameProperty('show', router.page)); + spyOn(router.page, JSCompiler_renameProperty('show', router.page)). + and.callFake(async (path) => new Context(path)); }); it('should navigate to the given path', () => { @@ -221,8 +222,14 @@ describe('Router', () => { }); expect(router.page.show).toHaveBeenCalledWith('/account/1234/documents/6789'); }); + it('should resolve to a Context', async () => { + const rp = await router.go('/A'); + expect(rp instanceof Context); + }); }); + + describe('query context', () => { afterEach(() => { // Remove the callback added in the test. From ed777a8d87de1f8245bf0b3a42d863a9abd9bbae Mon Sep 17 00:00:00 2001 From: John Robinson Date: Mon, 30 Oct 2023 13:01:36 -0400 Subject: [PATCH 4/4] chore: minor version bump -> 3.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f849bb..687da95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jack-henry/web-component-router", - "version": "3.0.3", + "version": "3.1.0", "description": "Web Components Router", "main": "router.js", "type": "module",