@@ -4,7 +4,7 @@ import { connectionStore } from '../store'
44
55const MOCK_IP = 'MOCK_IP'
66const MOCK_ROBOT = 'MOCK_ROBOT'
7- const MOCK_WINDOW = { } as any
7+ const MOCK_WINDOW = { once : ( ) => { } } as any
88const MOCK_CLIENT = { connected : true } as any
99const MOCK_TOPIC = 'MOCK_TOPIC' as any
1010
@@ -13,10 +13,12 @@ describe('ConnectionStore', () => {
1313 connectionStore . clearStore ( )
1414 } )
1515
16- describe ( 'getBrowserWindow' , ( ) => {
17- it ( 'should return the browser window' , ( ) => {
18- connectionStore . setBrowserWindow ( MOCK_WINDOW )
19- expect ( connectionStore . getBrowserWindow ( ) ) . toBe ( MOCK_WINDOW )
16+ describe ( 'getBrowserWindows' , ( ) => {
17+ it ( 'should return a set containing the browser window' , ( ) => {
18+ connectionStore . addBrowserWindow ( MOCK_WINDOW )
19+ const windows = connectionStore . getBrowserWindows ( )
20+ expect ( windows ) . toBeInstanceOf ( Set )
21+ expect ( windows . has ( MOCK_WINDOW ) ) . toBe ( true )
2022 } )
2123 } )
2224
@@ -92,10 +94,11 @@ describe('ConnectionStore', () => {
9294 } )
9395 } )
9496
95- describe ( 'setBrowserWindow' , ( ) => {
96- it ( 'should set the browser window' , ( ) => {
97- connectionStore . setBrowserWindow ( MOCK_WINDOW )
98- expect ( connectionStore . getBrowserWindow ( ) ) . toBe ( MOCK_WINDOW )
97+ describe ( 'addBrowserWindow' , ( ) => {
98+ it ( 'should add the browser window to the set' , ( ) => {
99+ connectionStore . addBrowserWindow ( MOCK_WINDOW )
100+ const windows = connectionStore . getBrowserWindows ( )
101+ expect ( windows . has ( MOCK_WINDOW ) ) . toBe ( true )
99102 } )
100103 } )
101104
@@ -211,12 +214,12 @@ describe('ConnectionStore', () => {
211214 describe ( 'clearStore' , ( ) => {
212215 it ( 'should clear all connections and robot names' , async ( ) => {
213216 await connectionStore . setPendingConnection ( MOCK_ROBOT )
214- connectionStore . setBrowserWindow ( MOCK_WINDOW )
217+ connectionStore . addBrowserWindow ( MOCK_WINDOW )
215218 expect ( connectionStore . getAllBrokersInStore ( ) ) . not . toEqual ( [ ] )
216- expect ( connectionStore . getBrowserWindow ( ) ) . not . toBeNull ( )
219+ expect ( connectionStore . getBrowserWindows ( ) . size ) . toBeGreaterThan ( 0 )
217220 connectionStore . clearStore ( )
218221 expect ( connectionStore . getAllBrokersInStore ( ) ) . toEqual ( [ ] )
219- expect ( connectionStore . getBrowserWindow ( ) ) . toBeNull ( )
222+ expect ( connectionStore . getBrowserWindows ( ) . size ) . toBe ( 0 )
220223 } )
221224 } )
222225
0 commit comments