Skip to content

Commit

Permalink
Merge pull request #69 from Banno/async-go
Browse files Browse the repository at this point in the history
fix: make router.go async
  • Loading branch information
ChadKillingsworth authored Nov 1, 2023
2 parents 1ee4787 + ed777a8 commit 605e09e
Show file tree
Hide file tree
Showing 3 changed files with 12 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.2",
"version": "3.1.0",
"description": "Web Components Router",
"main": "router.js",
"type": "module",
Expand Down
5 changes: 3 additions & 2 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<!Context>}
*/
go(path, params) {
async go(path, params) {
path = this.url(path, params);
this.page.show(path);
return this.page.show(path);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion test/router-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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.
Expand Down

0 comments on commit 605e09e

Please sign in to comment.