@@ -10,21 +10,21 @@ import { LobbyConnection } from './connection.js';
1010
1111describe ( 'lobby' , ( ) => {
1212 let lobby ;
13- let gameInstance1 , gameInstance2 ;
13+ let room1 , room2 ;
1414 let jsonResult = [ ] ;
1515 let nextStatus = 200 ;
1616
1717 beforeEach ( async ( ) => {
18- gameInstance1 = { gameID : 'gameID_1' , players : [ { id : '0' } ] } ;
19- gameInstance2 = { gameID : 'gameID_2' , players : [ { id : '1' } ] } ;
18+ room1 = { gameID : 'gameID_1' , players : [ { id : '0' } ] } ;
19+ room2 = { gameID : 'gameID_2' , players : [ { id : '1' } ] } ;
2020 // result of connection requests
2121 jsonResult = [
2222 ( ) => [ 'game1' , 'game2' ] ,
2323 ( ) => {
24- return { gameInstances : [ gameInstance1 ] } ;
24+ return { rooms : [ room1 ] } ;
2525 } ,
2626 ( ) => {
27- return { gameInstances : [ gameInstance2 ] } ;
27+ return { rooms : [ room2 ] } ;
2828 } ,
2929 ] ;
3030 let nextResult = jsonResult . shift . bind ( jsonResult ) ;
@@ -60,7 +60,7 @@ describe('lobby', () => {
6060 describe ( 'get list of rooms' , ( ) => {
6161 test ( 'when the server requests succeed' , async ( ) => {
6262 expect ( fetch ) . toHaveBeenCalledTimes ( 3 ) ;
63- expect ( lobby . gameInstances ) . toEqual ( [ gameInstance1 , gameInstance2 ] ) ;
63+ expect ( lobby . rooms ) . toEqual ( [ room1 , room2 ] ) ;
6464 } ) ;
6565 test ( 'when the server request fails' , async ( ) => {
6666 nextStatus = 404 ;
@@ -69,7 +69,7 @@ describe('lobby', () => {
6969 } catch ( error ) {
7070 expect ( error ) . toBeInstanceOf ( Error ) ;
7171 }
72- expect ( lobby . gameInstances ) . toEqual ( [ ] ) ;
72+ expect ( lobby . rooms ) . toEqual ( [ ] ) ;
7373 } ) ;
7474 } ) ;
7575
@@ -83,7 +83,7 @@ describe('lobby', () => {
8383 test ( 'when the room exists' , async ( ) => {
8484 await lobby . join ( 'game1' , 'gameID_1' , '0' ) ;
8585 expect ( fetch ) . toHaveBeenCalledTimes ( 4 ) ;
86- expect ( lobby . gameInstances [ 0 ] . players [ 0 ] ) . toEqual ( {
86+ expect ( lobby . rooms [ 0 ] . players [ 0 ] ) . toEqual ( {
8787 id : '0' ,
8888 name : 'Bob' ,
8989 } ) ;
@@ -95,10 +95,10 @@ describe('lobby', () => {
9595 } catch ( error ) {
9696 expect ( error ) . toBeInstanceOf ( Error ) ;
9797 }
98- expect ( lobby . gameInstances ) . toEqual ( [ gameInstance1 , gameInstance2 ] ) ;
98+ expect ( lobby . rooms ) . toEqual ( [ room1 , room2 ] ) ;
9999 } ) ;
100100 test ( 'when the seat is not available' , async ( ) => {
101- gameInstance1 . players [ 0 ] . name = 'Bob' ;
101+ room1 . players [ 0 ] . name = 'Bob' ;
102102 try {
103103 await lobby . join ( 'game1' , 'gameID_3' , '0' ) ;
104104 } catch ( error ) {
@@ -114,7 +114,7 @@ describe('lobby', () => {
114114 }
115115 } ) ;
116116 test ( 'when the player has already joined another game' , async ( ) => {
117- gameInstance2 . players [ 0 ] . name = 'Bob' ;
117+ room2 . players [ 0 ] . name = 'Bob' ;
118118 try {
119119 await lobby . join ( 'game1' , 'gameID_1' , '0' ) ;
120120 } catch ( error ) {
@@ -138,7 +138,7 @@ describe('lobby', () => {
138138 test ( 'when the room exists' , async ( ) => {
139139 await lobby . leave ( 'game1' , 'gameID_1' ) ;
140140 expect ( fetch ) . toHaveBeenCalledTimes ( 5 ) ;
141- expect ( lobby . gameInstances ) . toEqual ( [ gameInstance1 , gameInstance2 ] ) ;
141+ expect ( lobby . rooms ) . toEqual ( [ room1 , room2 ] ) ;
142142 } ) ;
143143 test ( 'when the room does not exist' , async ( ) => {
144144 try {
@@ -147,7 +147,7 @@ describe('lobby', () => {
147147 expect ( error ) . toBeInstanceOf ( Error ) ;
148148 }
149149 expect ( fetch ) . toHaveBeenCalledTimes ( 4 ) ;
150- expect ( lobby . gameInstances ) . toEqual ( [ gameInstance1 , gameInstance2 ] ) ;
150+ expect ( lobby . rooms ) . toEqual ( [ room1 , room2 ] ) ;
151151 } ) ;
152152 test ( 'when the player is not in the room' , async ( ) => {
153153 await lobby . leave ( 'game1' , 'gameID_1' ) ;
@@ -172,7 +172,7 @@ describe('lobby', () => {
172172 beforeEach ( async ( ) => { } ) ;
173173 test ( 'when the player leaves the lobby' , async ( ) => {
174174 await lobby . disconnect ( ) ;
175- expect ( lobby . gameInstances ) . toEqual ( [ ] ) ;
175+ expect ( lobby . rooms ) . toEqual ( [ ] ) ;
176176 } ) ;
177177 test ( 'when the player had joined a room' , async ( ) => {
178178 // result of request 'join'
@@ -185,7 +185,7 @@ describe('lobby', () => {
185185 return { } ;
186186 } ) ;
187187 await lobby . disconnect ( ) ;
188- expect ( lobby . gameInstances ) . toEqual ( [ ] ) ;
188+ expect ( lobby . rooms ) . toEqual ( [ ] ) ;
189189 } ) ;
190190 } ) ;
191191
@@ -232,7 +232,7 @@ describe('lobby', () => {
232232 } ) ;
233233 test ( 'get list of rooms for supported games' , async ( ) => {
234234 expect ( fetch ) . toHaveBeenCalledTimes ( 2 ) ;
235- expect ( lobby . gameInstances ) . toEqual ( [ gameInstance1 ] ) ;
235+ expect ( lobby . rooms ) . toEqual ( [ room1 ] ) ;
236236 } ) ;
237237 } ) ;
238238} ) ;
0 commit comments