@@ -53,6 +53,92 @@ export function main() {
5353 } ) ;
5454 } ) ;
5555
56+ describe ( "adding children" , ( ) => {
57+ it ( "should add child watch group" , ( ) => {
58+ var parent = new WatchGroup ( null , null ) ;
59+ var child1 = new WatchGroup ( null , null ) ;
60+ var child2 = new WatchGroup ( null , null ) ;
61+ parent . addChild ( child1 ) ;
62+ parent . addChild ( child2 ) ;
63+
64+ expect ( parent . childHead ) . toBe ( child1 ) ;
65+ expect ( parent . childTail ) . toBe ( child2 ) ;
66+
67+ expect ( child1 . next ) . toBe ( child2 ) ;
68+ expect ( child2 . prev ) . toBe ( child1 ) ;
69+ } ) ;
70+
71+ it ( "should link all records" , ( ) => {
72+ var parent = new WatchGroup ( null , null ) ;
73+ var parentRecord = createRecord ( parent ) ;
74+ parent . addRecord ( parentRecord ) ;
75+
76+ var child = new WatchGroup ( null , null ) ;
77+ var childRecord = createRecord ( child ) ;
78+ child . addRecord ( childRecord ) ;
79+
80+ parent . addChild ( child ) ;
81+
82+ expect ( parent . headRecord ) . toBe ( parentRecord ) ;
83+ expect ( parent . tailRecord ) . toBe ( childRecord ) ;
84+
85+ expect ( parent . headEnabledRecord ) . toBe ( parentRecord ) ;
86+ expect ( parent . tailEnabledRecord ) . toBe ( childRecord ) ;
87+
88+ expect ( parentRecord . next ) . toBe ( childRecord ) ;
89+ expect ( childRecord . prev ) . toBe ( parentRecord ) ;
90+ } ) ;
91+
92+ it ( "should work when parent has no records" , ( ) => {
93+ var parent = new WatchGroup ( null , null ) ;
94+
95+ var child = new WatchGroup ( null , null ) ;
96+ var childRecord = createRecord ( child ) ;
97+ child . addRecord ( childRecord ) ;
98+
99+ parent . addChild ( child ) ;
100+
101+ expect ( parent . headRecord ) . toBe ( childRecord ) ;
102+ expect ( parent . tailRecord ) . toBe ( childRecord ) ;
103+
104+ expect ( parent . headEnabledRecord ) . toBe ( childRecord ) ;
105+ expect ( parent . tailEnabledRecord ) . toBe ( childRecord ) ;
106+ } ) ;
107+
108+ it ( "should work when parent has no records and first child has no records" , ( ) => {
109+ var parent = new WatchGroup ( null , null ) ;
110+ var firstChild = new WatchGroup ( null , null ) ;
111+ parent . addChild ( firstChild ) ;
112+
113+ var child = new WatchGroup ( null , null ) ;
114+ var childRecord = createRecord ( child ) ;
115+ child . addRecord ( childRecord ) ;
116+
117+ parent . addChild ( child ) ;
118+
119+ expect ( parent . headRecord ) . toBe ( childRecord ) ;
120+ expect ( parent . tailRecord ) . toBe ( childRecord ) ;
121+
122+ expect ( parent . headEnabledRecord ) . toBe ( childRecord ) ;
123+ expect ( parent . tailEnabledRecord ) . toBe ( childRecord ) ;
124+ } ) ;
125+
126+ it ( "should work when second child has no records" , ( ) => {
127+ var parent = new WatchGroup ( null , null ) ;
128+
129+ var firstChild = new WatchGroup ( null , null ) ;
130+ var childRecord = createRecord ( firstChild ) ;
131+ firstChild . addRecord ( childRecord ) ;
132+ parent . addChild ( firstChild ) ;
133+
134+ var secondChild = new WatchGroup ( null , null ) ;
135+ parent . addChild ( secondChild ) ;
136+
137+ expect ( parent . childHead ) . toBe ( firstChild ) ;
138+ expect ( parent . childTail ) . toBe ( secondChild ) ;
139+ } ) ;
140+ } ) ;
141+
56142 describe ( "enabling/disabling records" , ( ) => {
57143 it ( "should disable a single record" , ( ) => {
58144 var wg = new WatchGroup ( null , null ) ;
0 commit comments