11import { TestBed } from '@angular/core/testing' ;
2- import { take } from 'rxjs' ;
2+ import { of , take } from 'rxjs' ;
33import { v4 as uuid } from 'uuid' ;
44import { TabGroup } from './tab-group' ;
55import { TabInfo , TabStateService } from './tab-state.service' ;
@@ -8,8 +8,8 @@ describe('TabStateService', () => {
88 let service : TabStateService < string , TabInfo < string > > ;
99 const groupId = 'testGroup' ;
1010 const tabs : TabInfo < string > [ ] = [
11- { id : uuid ( ) , type : 'tab1' , headerText : 'Tab 1' , closeable : true , movable : true } ,
12- { id : uuid ( ) , type : 'tab2' , headerText : 'Tab 2' , closeable : false , movable : true }
11+ { id : uuid ( ) , type : 'tab1' , headerText$ : of ( 'Tab 1' ) , closeable : true , movable : true } ,
12+ { id : uuid ( ) , type : 'tab2' , headerText$ : of ( 'Tab 2' ) , closeable : false , movable : true }
1313 ] ;
1414
1515 beforeEach ( ( ) => {
@@ -49,8 +49,8 @@ describe('TabStateService', () => {
4949 const groupId1 : string = 'group1' ;
5050 const groupId2 : string = 'group2' ;
5151 const tabs : TabInfo < string > [ ] = [
52- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
53- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true }
52+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
53+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true }
5454 ] ;
5555 service [ 'groups' ] . set ( groupId1 , new TabGroup < string , any > ( groupId1 , tabs ) ) ;
5656 service [ 'groups' ] . set ( groupId2 , new TabGroup < string , any > ( groupId2 , tabs ) ) ;
@@ -72,12 +72,12 @@ describe('TabStateService', () => {
7272 const groupId1 : string = 'group1' ;
7373 const groupId2 : string = 'group2' ;
7474 const tabs1 : TabInfo < string > [ ] = [
75- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
76- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true }
75+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
76+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true }
7777 ] ;
7878 const tabs2 : TabInfo < string > [ ] = [
79- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true } ,
80- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true }
79+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true } ,
80+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true }
8181 ] ;
8282 service [ 'groups' ] . set ( groupId1 , new TabGroup < string , any > ( groupId1 , tabs1 ) ) ;
8383 service [ 'groups' ] . set ( groupId2 , new TabGroup < string , any > ( groupId2 , tabs2 ) ) ;
@@ -90,8 +90,8 @@ describe('TabStateService', () => {
9090 const groupId1 : string = 'group1' ;
9191 const groupId2 : string = 'group2' ;
9292 const tabs : TabInfo < string > [ ] = [
93- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
94- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true }
93+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
94+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true }
9595 ] ;
9696 service [ 'groups' ] . set ( groupId1 , new TabGroup < string , any > ( groupId1 , tabs ) ) ;
9797 service [ 'groups' ] . set ( groupId2 , new TabGroup < string , any > ( groupId2 , tabs ) ) ;
@@ -107,7 +107,7 @@ describe('TabStateService', () => {
107107 const tab : TabInfo < string > = {
108108 id : uuid ( ) ,
109109 type : 'type-a' ,
110- headerText : 'Header' ,
110+ headerText$ : of ( 'Header' ) ,
111111 closeable : true ,
112112 movable : true
113113 } ;
@@ -121,7 +121,7 @@ describe('TabStateService', () => {
121121 const tab : TabInfo < string > = {
122122 id : uuid ( ) ,
123123 type : 'type-a' ,
124- headerText : 'Header' ,
124+ headerText$ : of ( 'Header' ) ,
125125 closeable : true ,
126126 movable : true
127127 } ;
@@ -137,14 +137,14 @@ describe('TabStateService', () => {
137137 {
138138 id : uuid ( ) ,
139139 type : 'type-a' ,
140- headerText : 'Header 1' ,
140+ headerText$ : of ( 'Header 1' ) ,
141141 closeable : true ,
142142 movable : true
143143 } ,
144144 {
145145 id : uuid ( ) ,
146146 type : 'type-a' ,
147- headerText : 'Header 2' ,
147+ headerText$ : of ( 'Header 2' ) ,
148148 closeable : true ,
149149 movable : true
150150 }
@@ -158,9 +158,9 @@ describe('TabStateService', () => {
158158 it ( 'should move a tab within the same group' , ( ) => {
159159 const groupId : string = 'source' ;
160160 const tabs : TabInfo < string > [ ] = [
161- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
162- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true } ,
163- { id : uuid ( ) , type : 'type-c' , headerText : 'Header 3' , closeable : true , movable : true }
161+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
162+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true } ,
163+ { id : uuid ( ) , type : 'type-c' , headerText$ : of ( 'Header 3' ) , closeable : true , movable : true }
164164 ] ;
165165 service [ 'groups' ] . set ( groupId , new TabGroup < string , any > ( groupId , tabs ) ) ;
166166 service . moveTab ( { groupId, index : 0 } , { groupId, index : 2 } ) ;
@@ -170,9 +170,9 @@ describe('TabStateService', () => {
170170 it ( 'should update selected index when moving a tab within the same group' , ( ) => {
171171 const groupId : string = 'source' ;
172172 const tabs : TabInfo < string > [ ] = [
173- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
174- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true } ,
175- { id : uuid ( ) , type : 'type-c' , headerText : 'Header 3' , closeable : true , movable : true }
173+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
174+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true } ,
175+ { id : uuid ( ) , type : 'type-c' , headerText$ : of ( 'Header 3' ) , closeable : true , movable : true }
176176 ] ;
177177 const group = new TabGroup < string , any > ( groupId , tabs ) ;
178178 service [ 'groups' ] . set ( groupId , group ) ;
@@ -198,12 +198,12 @@ describe('TabStateService', () => {
198198 const fromGroupId : string = 'source' ;
199199 const toGroupId : string = 'target' ;
200200 const fromTabs : TabInfo < string > [ ] = [
201- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
202- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true }
201+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
202+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true }
203203 ] ;
204204 const toTabs : TabInfo < string > [ ] = [
205- { id : uuid ( ) , type : 'type-c' , headerText : 'Header 3' , closeable : true , movable : true } ,
206- { id : uuid ( ) , type : 'type-d' , headerText : 'Header 4' , closeable : true , movable : true }
205+ { id : uuid ( ) , type : 'type-c' , headerText$ : of ( 'Header 3' ) , closeable : true , movable : true } ,
206+ { id : uuid ( ) , type : 'type-d' , headerText$ : of ( 'Header 4' ) , closeable : true , movable : true }
207207 ] ;
208208 service [ 'groups' ] . set ( fromGroupId , new TabGroup < string , any > ( fromGroupId , fromTabs ) ) ;
209209 service [ 'groups' ] . set ( toGroupId , new TabGroup < string , any > ( toGroupId , toTabs ) ) ;
@@ -216,14 +216,14 @@ describe('TabStateService', () => {
216216 const fromGroupId : string = 'source' ;
217217 const toGroupId : string = 'target' ;
218218 const fromTabs : TabInfo < string > [ ] = [
219- { id : uuid ( ) , type : 'type-a' , headerText : 'Header 1' , closeable : true , movable : true } ,
220- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 2' , closeable : true , movable : true } ,
221- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 3' , closeable : true , movable : true } ,
222- { id : uuid ( ) , type : 'type-b' , headerText : 'Header 4' , closeable : true , movable : true }
219+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Header 1' ) , closeable : true , movable : true } ,
220+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 2' ) , closeable : true , movable : true } ,
221+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 3' ) , closeable : true , movable : true } ,
222+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Header 4' ) , closeable : true , movable : true }
223223 ] ;
224224 const toTabs : TabInfo < string > [ ] = [
225- { id : uuid ( ) , type : 'type-c' , headerText : 'Header 3' , closeable : true , movable : true } ,
226- { id : uuid ( ) , type : 'type-d' , headerText : 'Header 4' , closeable : true , movable : true }
225+ { id : uuid ( ) , type : 'type-c' , headerText$ : of ( 'Header 3' ) , closeable : true , movable : true } ,
226+ { id : uuid ( ) , type : 'type-d' , headerText$ : of ( 'Header 4' ) , closeable : true , movable : true }
227227 ] ;
228228 const fromGroup = new TabGroup < string , any > ( fromGroupId , fromTabs ) ;
229229 const toGroup = new TabGroup < string , any > ( toGroupId , toTabs ) ;
@@ -251,17 +251,17 @@ describe('TabStateService', () => {
251251
252252 beforeEach ( ( ) => {
253253 sourceTabs = [
254- { id : uuid ( ) , type : 'type-a' , headerText : 'Source Header 1' , closeable : true , movable : true } ,
255- { id : uuid ( ) , type : 'type-b' , headerText : 'Source Header 2' , closeable : true , movable : true } ,
256- { id : uuid ( ) , type : 'type-b' , headerText : 'Source Header 3' , closeable : true , movable : true } ,
257- { id : uuid ( ) , type : 'type-b' , headerText : 'Source Header 4' , closeable : true , movable : true }
254+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Source Header 1' ) , closeable : true , movable : true } ,
255+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Source Header 2' ) , closeable : true , movable : true } ,
256+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Source Header 3' ) , closeable : true , movable : true } ,
257+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Source Header 4' ) , closeable : true , movable : true }
258258 ] ;
259259
260260 targetTabs = [
261- { id : uuid ( ) , type : 'type-a' , headerText : 'Target Header 1' , closeable : true , movable : true } ,
262- { id : uuid ( ) , type : 'type-b' , headerText : 'Target Header 2' , closeable : true , movable : true } ,
263- { id : uuid ( ) , type : 'type-b' , headerText : 'Target Header 3' , closeable : true , movable : true } ,
264- { id : uuid ( ) , type : 'type-b' , headerText : 'Target Header 4' , closeable : true , movable : true }
261+ { id : uuid ( ) , type : 'type-a' , headerText$ : of ( 'Target Header 1' ) , closeable : true , movable : true } ,
262+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Target Header 2' ) , closeable : true , movable : true } ,
263+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Target Header 3' ) , closeable : true , movable : true } ,
264+ { id : uuid ( ) , type : 'type-b' , headerText$ : of ( 'Target Header 4' ) , closeable : true , movable : true }
265265 ] ;
266266
267267 service [ 'groups' ] . set ( 'source' , new TabGroup < string , any > ( 'source' , sourceTabs ) ) ;
@@ -295,8 +295,20 @@ describe('TabStateService', () => {
295295
296296 it ( 'should add tabs to restore list and consolidated group when tabs are added after consolidation and before deconsolidation' , ( ) => {
297297 const tabsToAdd : TabInfo < string > [ ] = [
298- { id : uuid ( ) , type : 'type-c' , headerText : 'added source Source Header 5' , closeable : true , movable : true } ,
299- { id : uuid ( ) , type : 'type-c' , headerText : 'added source Source Header 6' , closeable : true , movable : true }
298+ {
299+ id : uuid ( ) ,
300+ type : 'type-c' ,
301+ headerText$ : of ( 'added source Source Header 5' ) ,
302+ closeable : true ,
303+ movable : true
304+ } ,
305+ {
306+ id : uuid ( ) ,
307+ type : 'type-c' ,
308+ headerText$ : of ( 'added source Source Header 6' ) ,
309+ closeable : true ,
310+ movable : true
311+ }
300312 ] ;
301313
302314 service . consolidateTabGroups ( 'target' ) ;
@@ -313,7 +325,7 @@ describe('TabStateService', () => {
313325 const tabToAdd : TabInfo < string > = {
314326 id : uuid ( ) ,
315327 type : 'type-c' ,
316- headerText : 'added source Source Header 5' ,
328+ headerText$ : of ( 'added source Source Header 5' ) ,
317329 closeable : true ,
318330 movable : true
319331 } ;
0 commit comments