@triptease/tt-navbar 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.34
2
+ * @triptease/tt-navbar v0.0.35
3
3
  */
4
4
 
5
5
  // src/urlMappings.ts
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent tt-navbar following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "tt-navbar",
6
- "version": "0.0.34",
6
+ "version": "0.0.35",
7
7
  "type": "module",
8
8
  "main": "dist/src/index.js",
9
9
  "module": "dist/src/index.js",
package/src/TtNavbar.ts CHANGED
@@ -67,14 +67,19 @@ export class TtNavbar extends LitElement {
67
67
  }
68
68
 
69
69
  public connectedCallback() {
70
-
70
+ // Listen for browser back/forward navigation
71
71
  window.addEventListener('popstate', this.setActiveState);
72
+
73
+ // Listen for Tetris programmatic navigation
74
+ window.addEventListener('tetris:navigate', this.setActiveState);
75
+
72
76
  super.connectedCallback();
73
77
  }
74
78
 
75
79
  public disconnectedCallback() {
76
-
77
80
  window.removeEventListener('popstate', this.setActiveState);
81
+ window.removeEventListener('tetris:navigate', this.setActiveState);
82
+
78
83
  super.disconnectedCallback();
79
84
  }
80
85
 
@@ -359,4 +359,25 @@ describe('TtNavbar', () => {
359
359
  expect(marketInsightsDetails).to.exist;
360
360
  expect(marketInsightsDetails.open).to.be.true;
361
361
  })
362
+
363
+ it('should set the active route when receives `tetris:navigate` event', async () => {
364
+ const navbar = await fixture<TtNavbar>(
365
+ `<tt-navbar client-key=${CLIENT_KEY}></tt-navbar>`
366
+ );
367
+ // eslint-disable-next-line no-restricted-globals
368
+ history.pushState({}, '', `/account/billing-management/${CLIENT_KEY}`)
369
+
370
+
371
+ // Dispatch the event to change to Channels route
372
+ const navigateEvent = new CustomEvent('tetris:navigate', {
373
+ });
374
+ window.dispatchEvent(navigateEvent);
375
+
376
+ await elementUpdated(navbar);
377
+ const anchor = navbar.shadowRoot!.querySelector('a[aria-current="page"]');
378
+
379
+ expect(anchor).to.exist;
380
+ expect(anchor!.textContent).to.include('Booking reconciliation');
381
+
382
+ })
362
383
  });