@@ -1169,7 +1169,18 @@ const runTests = async (van, msgDom, { debug }) => {
1169
1169
// We want to test the garbage-collection process is in place to ensure obsolete bindings and
1170
1170
// derivations can be cleaned up.
1171
1171
const gcTests = {
1172
- long_derivedDom : withHiddenDom ( async ( hiddenDom ) => {
1172
+ bindingBasic : withHiddenDom ( async ( hiddenDom ) => {
1173
+ const counter = van . state ( 0 ) ;
1174
+ const bindingsPropKey = Object . entries ( counter )
1175
+ . find ( ( [ _ , v ] ) => Array . isArray ( v ) ) [ 0 ] ;
1176
+ van . add ( hiddenDom , ( ) => span ( `Counter: ${ counter . val } ` ) ) ;
1177
+ for ( let i = 0 ; i < 100 ; ++ i )
1178
+ ++ counter . val ;
1179
+ await sleep ( waitMsOnDomUpdates ) ;
1180
+ assertEq ( hiddenDom . innerHTML , "<span>Counter: 100</span>" ) ;
1181
+ assertBetween ( counter [ bindingsPropKey ] . length , 1 , 3 ) ;
1182
+ } ) ,
1183
+ long_nestedBinding : withHiddenDom ( async ( hiddenDom ) => {
1173
1184
const renderPre = van . state ( false ) ;
1174
1185
const text = van . state ( "Text" ) ;
1175
1186
const bindingsPropKey = Object . entries ( renderPre )
@@ -1185,7 +1196,7 @@ const runTests = async (van, msgDom, { debug }) => {
1185
1196
assertBetween ( renderPre [ bindingsPropKey ] . length , 1 , 3 ) ;
1186
1197
assertBetween ( text [ bindingsPropKey ] . length , 1 , 3 ) ;
1187
1198
} ) ,
1188
- long_conditionalDomFunc : withHiddenDom ( async ( hiddenDom ) => {
1199
+ long_conditionalBinding : withHiddenDom ( async ( hiddenDom ) => {
1189
1200
const cond = van . state ( true ) ;
1190
1201
const a = van . state ( 0 ) , b = van . state ( 0 ) , c = van . state ( 0 ) , d = van . state ( 0 ) ;
1191
1202
const bindingsPropKey = Object . entries ( cond )
@@ -1206,7 +1217,7 @@ const runTests = async (van, msgDom, { debug }) => {
1206
1217
await sleep ( 1000 ) ;
1207
1218
allStates . every ( s => assertBetween ( s [ bindingsPropKey ] . length , 1 , 3 ) ) ;
1208
1219
} ) ,
1209
- long_deriveBasic : async ( ) => {
1220
+ deriveBasic : ( ) => {
1210
1221
const history = [ ] ;
1211
1222
const a = van . state ( 0 ) ;
1212
1223
const listenersPropKey = Object . entries ( a )
@@ -1215,8 +1226,6 @@ const runTests = async (van, msgDom, { debug }) => {
1215
1226
for ( let i = 0 ; i < 100 ; ++ i )
1216
1227
++ a . val ;
1217
1228
assertEq ( history . length , 101 ) ;
1218
- // Wait until GC kicks in
1219
- await sleep ( 1000 ) ;
1220
1229
assertBetween ( a [ listenersPropKey ] . length , 1 , 3 ) ;
1221
1230
} ,
1222
1231
long_deriveInBindingFunc : withHiddenDom ( async ( hiddenDom ) => {
0 commit comments