@@ -34,7 +34,11 @@ describe('as', function() {
3434 expect ( fragment ) . html ( '<div></div>' ) ;
3535 } ) ;
3636
37- it ( 'HTML element `as-object` property' , function ( ) {
37+ async function nextTick ( ) {
38+ return new Promise ( ( resolve ) => process . nextTick ( resolve ) ) ;
39+ }
40+
41+ it ( 'HTML element `as-object` property' , async function ( ) {
3842 const { app } = runner . createHarness ( ) ;
3943 app . views . register ( 'Body' ,
4044 '<ul>' +
@@ -58,24 +62,31 @@ describe('as', function() {
5862 expect ( fragment ) . html ( '<ul><li>A</li><li>B</li><li>C</li></ul>' ) ;
5963
6064 page . model . remove ( '_page.items' , 1 ) ;
65+
66+ // templates.ts#L2342 not processing delete of property until nexttick
67+ // https://github.com/derbyjs/derby/blob/master/src/templates/templates.ts#L2342-L2347
68+ // unsure if this is a change since these were run in browser
69+ await nextTick ( ) ;
6170 expect ( page . nested . map ) . all . keys ( 'a' , 'c' ) ;
6271 expect ( page . nested . map . a ) . html ( '<li>A</li>' ) ;
6372 expect ( page . nested . map . c ) . html ( '<li>C</li>' ) ;
6473 expect ( fragment ) . html ( '<ul><li>A</li><li>C</li></ul>' ) ;
6574
6675 page . model . unshift ( '_page.items' , { id : 'd' , text : 'D' } ) ;
76+ await nextTick ( ) ;
6777 expect ( page . nested . map ) . all . keys ( 'a' , 'c' , 'd' ) ;
6878 expect ( page . nested . map . a ) . html ( '<li>A</li>' ) ;
6979 expect ( page . nested . map . c ) . html ( '<li>C</li>' ) ;
7080 expect ( page . nested . map . d ) . html ( '<li>D</li>' ) ;
7181 expect ( fragment ) . html ( '<ul><li>D</li><li>A</li><li>C</li></ul>' ) ;
7282
7383 page . model . del ( '_page.items' ) ;
84+ await nextTick ( ) ;
7485 expect ( page . nested . map ) . eql ( { } ) ;
7586 expect ( fragment ) . html ( '<ul></ul>' ) ;
7687 } ) ;
7788
78- it ( 'Component `as-object` property' , function ( ) {
89+ it ( 'Component `as-object` property' , async function ( ) {
7990 const { app } = runner . createHarness ( ) ;
8091 app . views . register ( 'Body' ,
8192 '<ul>' +
@@ -107,6 +118,10 @@ describe('as', function() {
107118 expect ( fragment ) . html ( '<ul><li>A</li><li>B</li><li>C</li></ul>' ) ;
108119
109120 page . model . remove ( '_page.items' , 1 ) ;
121+ // templates.ts#L2342 not processing delete of property until nexttick
122+ // https://github.com/derbyjs/derby/blob/master/src/templates/templates.ts#L2342-L2347
123+ // unsure if this is a change since these were run in browser
124+ await nextTick ( ) ;
110125 expect ( page . nested . map ) . all . keys ( 'a' , 'c' ) ;
111126 expect ( page . nested . map . a ) . instanceof ( Item ) ;
112127 expect ( page . nested . map . c ) . instanceof ( Item ) ;
@@ -115,6 +130,7 @@ describe('as', function() {
115130 expect ( fragment ) . html ( '<ul><li>A</li><li>C</li></ul>' ) ;
116131
117132 page . model . unshift ( '_page.items' , { id : 'd' , text : 'D' } ) ;
133+ await nextTick ( ) ;
118134 expect ( page . nested . map ) . all . keys ( 'a' , 'c' , 'd' ) ;
119135 expect ( page . nested . map . a ) . instanceof ( Item ) ;
120136 expect ( page . nested . map . c ) . instanceof ( Item ) ;
@@ -125,7 +141,7 @@ describe('as', function() {
125141 expect ( fragment ) . html ( '<ul><li>D</li><li>A</li><li>C</li></ul>' ) ;
126142
127143 page . model . del ( '_page.items' ) ;
128- console . log ( '_page.items' , items . get ( ) ) ;
144+ await nextTick ( ) ;
129145 expect ( page . nested . map ) . eql ( { } ) ;
130146 expect ( fragment ) . html ( '<ul></ul>' ) ;
131147 } ) ;
0 commit comments