@@ -3,12 +3,13 @@ import { describe, expect, it } from 'vitest';
33
44import type { AppModulesInstance } from '@equinor/fusion-framework-module-app' ;
55import type { ContextModule } from '@equinor/fusion-framework-module-context' ;
6- import type { ContextNavigationPluginArgs } from '../plugin' ;
6+ import type { ContextNavigationPluginArgs } from '../create-context-navigation- plugin' ;
77
8- import { activeAppNavigationEvents$ } from '../operators/active-app-navigation-events' ;
8+ import { activeAppNavigationEvents } from '../operators/active-app-navigation-events' ;
99
1010describe ( 'activeAppNavigationEvents$' , ( ) => {
1111 it ( 'emits when app, instance, and navigation state are all present' , ( ) => {
12+ // Test double — only the context property is accessed by the operator under test
1213 const appModules = { context : { } } as unknown as AppModulesInstance < [ ContextModule ] > ;
1314 const navigationState$ = new Subject < unknown > ( ) ;
1415
@@ -18,13 +19,15 @@ describe('activeAppNavigationEvents$', () => {
1819 manifest$ : new BehaviorSubject ( null ) ,
1920 } ) ;
2021
22+ // Test double — only current$ is read by the operator under test
2123 const app = { current$ : currentApp$ } as unknown as ContextNavigationPluginArgs [ 'app' ] ;
24+ // Test double — only state$ is read by the operator under test
2225 const navigation = {
2326 state$ : navigationState$ ,
2427 } as unknown as ContextNavigationPluginArgs [ 'navigation' ] ;
2528
2629 const emissions : unknown [ ] = [ ] ;
27- const sub = activeAppNavigationEvents$ ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
30+ const sub = activeAppNavigationEvents ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
2831
2932 navigationState$ . next ( { } ) ;
3033
@@ -38,13 +41,15 @@ describe('activeAppNavigationEvents$', () => {
3841 const navigationState$ = new Subject < unknown > ( ) ;
3942 const currentApp$ = new BehaviorSubject ( null ) ;
4043
44+ // Test double — only current$ is read by the operator under test
4145 const app = { current$ : currentApp$ } as unknown as ContextNavigationPluginArgs [ 'app' ] ;
46+ // Test double — only state$ is read by the operator under test
4247 const navigation = {
4348 state$ : navigationState$ ,
4449 } as unknown as ContextNavigationPluginArgs [ 'navigation' ] ;
4550
4651 const emissions : unknown [ ] = [ ] ;
47- const sub = activeAppNavigationEvents$ ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
52+ const sub = activeAppNavigationEvents ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
4853
4954 navigationState$ . next ( { } ) ;
5055
@@ -60,13 +65,15 @@ describe('activeAppNavigationEvents$', () => {
6065 manifest$ : new BehaviorSubject ( null ) ,
6166 } ) ;
6267
68+ // Test double — only current$ is read by the operator under test
6369 const app = { current$ : currentApp$ } as unknown as ContextNavigationPluginArgs [ 'app' ] ;
70+ // Test double — only state$ is read by the operator under test
6471 const navigation = {
6572 state$ : navigationState$ ,
6673 } as unknown as ContextNavigationPluginArgs [ 'navigation' ] ;
6774
6875 const emissions : unknown [ ] = [ ] ;
69- const sub = activeAppNavigationEvents$ ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
76+ const sub = activeAppNavigationEvents ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
7077
7178 navigationState$ . next ( { } ) ;
7279
@@ -75,6 +82,7 @@ describe('activeAppNavigationEvents$', () => {
7582 } ) ;
7683
7784 it ( 're-emits on each navigation state change' , ( ) => {
85+ // Test double — only the context property is accessed by the operator under test
7886 const appModules = { context : { } } as unknown as AppModulesInstance < [ ContextModule ] > ;
7987 const navigationState$ = new Subject < unknown > ( ) ;
8088
@@ -84,13 +92,15 @@ describe('activeAppNavigationEvents$', () => {
8492 manifest$ : new BehaviorSubject ( null ) ,
8593 } ) ;
8694
95+ // Test double — only current$ is read by the operator under test
8796 const app = { current$ : currentApp$ } as unknown as ContextNavigationPluginArgs [ 'app' ] ;
97+ // Test double — only state$ is read by the operator under test
8898 const navigation = {
8999 state$ : navigationState$ ,
90100 } as unknown as ContextNavigationPluginArgs [ 'navigation' ] ;
91101
92102 const emissions : unknown [ ] = [ ] ;
93- const sub = activeAppNavigationEvents$ ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
103+ const sub = activeAppNavigationEvents ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
94104
95105 navigationState$ . next ( { } ) ;
96106 navigationState$ . next ( { } ) ;
@@ -101,9 +111,11 @@ describe('activeAppNavigationEvents$', () => {
101111 } ) ;
102112
103113 it ( 'switches to new app when current app changes' , ( ) => {
114+ // Test double — only the context property is accessed by the operator under test
104115 const appModulesA = { context : { name : 'A' } } as unknown as AppModulesInstance <
105116 [ ContextModule ]
106117 > ;
118+ // Test double — only the context property is accessed by the operator under test
107119 const appModulesB = { context : { name : 'B' } } as unknown as AppModulesInstance <
108120 [ ContextModule ]
109121 > ;
@@ -115,13 +127,15 @@ describe('activeAppNavigationEvents$', () => {
115127 manifest$ : new BehaviorSubject ( null ) ,
116128 } ) ;
117129
130+ // Test double — only current$ is read by the operator under test
118131 const app = { current$ : currentApp$ } as unknown as ContextNavigationPluginArgs [ 'app' ] ;
132+ // Test double — only state$ is read by the operator under test
119133 const navigation = {
120134 state$ : navigationState$ ,
121135 } as unknown as ContextNavigationPluginArgs [ 'navigation' ] ;
122136
123137 const emissions : Array < { appKey : string } > = [ ] ;
124- const sub = activeAppNavigationEvents$ ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
138+ const sub = activeAppNavigationEvents ( app , navigation ) . subscribe ( ( val ) => emissions . push ( val ) ) ;
125139
126140 navigationState$ . next ( { } ) ;
127141 expect ( emissions [ 0 ] ?. appKey ) . toBe ( 'app-a' ) ;
0 commit comments