@@ -51,6 +51,15 @@ class VirtualDelegate implements IListVirtualDelegate<Element> {
5151 getTemplateId ( element : Element ) : string { return 'default' ; }
5252}
5353
54+ class DataSource implements IAsyncDataSource < Element , Element > {
55+ hasChildren ( element : Element ) : boolean {
56+ return ! ! element . children && element . children . length > 0 ;
57+ }
58+ getChildren ( element : Element ) : Promise < Element [ ] > {
59+ return Promise . resolve ( element . children || [ ] ) ;
60+ }
61+ }
62+
5463class Model {
5564
5665 constructor ( readonly root : Element ) { }
@@ -65,23 +74,14 @@ suite('AsyncDataTree', function () {
6574 test ( 'Collapse state should be preserved across refresh calls' , async ( ) => {
6675 const container = document . createElement ( 'div' ) ;
6776
68- const dataSource = new class implements IAsyncDataSource < Element , Element > {
69- hasChildren ( element : Element ) : boolean {
70- return ! ! element . children && element . children . length > 0 ;
71- }
72- getChildren ( element : Element ) : Promise < Element [ ] > {
73- return Promise . resolve ( element . children || [ ] ) ;
74- }
75- } ;
76-
7777 const model = new Model ( {
7878 id : 'root' ,
7979 children : [ {
8080 id : 'a'
8181 } ]
8282 } ) ;
8383
84- const tree = new AsyncDataTree < Element , Element > ( 'test' , container , new VirtualDelegate ( ) , [ new Renderer ( ) ] , dataSource , { identityProvider : new IdentityProvider ( ) } ) ;
84+ const tree = new AsyncDataTree < Element , Element > ( 'test' , container , new VirtualDelegate ( ) , [ new Renderer ( ) ] , new DataSource ( ) , { identityProvider : new IdentityProvider ( ) } ) ;
8585 tree . layout ( 200 ) ;
8686 assert . equal ( container . querySelectorAll ( '.monaco-list-row' ) . length , 0 ) ;
8787
@@ -212,23 +212,14 @@ suite('AsyncDataTree', function () {
212212 test ( 'resolved collapsed nodes which lose children should lose twistie as well' , async ( ) => {
213213 const container = document . createElement ( 'div' ) ;
214214
215- const dataSource = new class implements IAsyncDataSource < Element , Element > {
216- hasChildren ( element : Element ) : boolean {
217- return ! ! element . children && element . children . length > 0 ;
218- }
219- getChildren ( element : Element ) : Promise < Element [ ] > {
220- return Promise . resolve ( element . children || [ ] ) ;
221- }
222- } ;
223-
224215 const model = new Model ( {
225216 id : 'root' ,
226217 children : [ {
227218 id : 'a' , children : [ { id : 'aa' } , { id : 'ab' } , { id : 'ac' } ]
228219 } ]
229220 } ) ;
230221
231- const tree = new AsyncDataTree < Element , Element > ( 'test' , container , new VirtualDelegate ( ) , [ new Renderer ( ) ] , dataSource , { identityProvider : new IdentityProvider ( ) } ) ;
222+ const tree = new AsyncDataTree < Element , Element > ( 'test' , container , new VirtualDelegate ( ) , [ new Renderer ( ) ] , new DataSource ( ) , { identityProvider : new IdentityProvider ( ) } ) ;
232223 tree . layout ( 200 ) ;
233224
234225 await tree . setInput ( model . root ) ;
0 commit comments