@@ -220,6 +220,8 @@ myTuple = 1,2,3,4,5,6,7,8,9
220220 { name : 'myDataframe' , value : ' 0\n0 0.00000\n1 2.00004\n2 4.00008\n3 6.00012\n4 8.00016\n5 10.00020\n6 12.00024\n7 14.00028\n8 16.00032\n' , supportsDataExplorer : true , type : 'DataFrame' , size : 54 , shape : '' , count : 0 , truncated : false } ,
221221 { name : 'myFloat' , value : '9999.9999' , supportsDataExplorer : false , type : 'float' , size : 58 , shape : '' , count : 0 , truncated : false } ,
222222 { name : 'myInt' , value : '99999999' , supportsDataExplorer : false , type : 'int' , size : 56 , shape : '' , count : 0 , truncated : false } ,
223+ { name : 'mynpArray' , value : `[0.00000000e+00 2.00004000e+00 4.00008000e+00 ... 9.99959999e+04
224+ 9.99980000e+04 1.00000000e+05]` , supportsDataExplorer : true , type : 'ndarray' , size : 54 , shape : '' , count : 0 , truncated : false } ,
223225 { name : 'mySeries' , value : `0 0.00000
2242261 2.00004
2252272 4.00008
@@ -230,9 +232,44 @@ myTuple = 1,2,3,4,5,6,7,8,9
2302327 14.00028
2312338 16.00032
2322349 ` , supportsDataExplorer : true , type : 'Series' , size : 54 , shape : '' , count : 0 , truncated : false } ,
233- { name : 'myTuple' , value : '(1, 2, 3, 4, 5, 6, 7, 8, 9)' , supportsDataExplorer : false , type : 'tuple' , size : 54 , shape : '' , count : 0 , truncated : false } ,
234- { name : 'mynpArray' , value : `[0.00000000e+00 2.00004000e+00 4.00008000e+00 ... 9.99959999e+04
235- 9.99980000e+04 1.00000000e+05]` , supportsDataExplorer : true , type : 'ndarray' , size : 54 , shape : '' , count : 0 , truncated : false }
235+ { name : 'myTuple' , value : '(1, 2, 3, 4, 5, 6, 7, 8, 9)' , supportsDataExplorer : false , type : 'tuple' , size : 54 , shape : '' , count : 0 , truncated : false }
236+ ] ;
237+ verifyVariables ( wrapper , targetVariables ) ;
238+ } , ( ) => { return ioc ; } ) ;
239+
240+ runMountedTest ( 'Variable explorer - Sorting' , async ( wrapper ) => {
241+ const basicCode : string = `b = 2
242+ c = 3
243+ stra = 'a'
244+ strb = 'b'
245+ strc = 'c'` ;
246+
247+ openVariableExplorer ( wrapper ) ;
248+
249+ await addCode ( getOrCreateHistory , wrapper , 'a=1\na' ) ;
250+ await addCode ( getOrCreateHistory , wrapper , basicCode , 4 ) ;
251+
252+ await waitForUpdate ( wrapper , VariableExplorer , 7 ) ;
253+
254+ let targetVariables : IJupyterVariable [ ] = [
255+ { name : 'a' , value : '1' , supportsDataExplorer : false , type : 'int' , size : 54 , shape : '' , count : 0 , truncated : false } ,
256+ { name : 'b' , value : '2' , supportsDataExplorer : false , type : 'int' , size : 54 , shape : '' , count : 0 , truncated : false } ,
257+ { name : 'c' , value : '3' , supportsDataExplorer : false , type : 'int' , size : 54 , shape : '' , count : 0 , truncated : false } ,
258+ { name : 'stra' , value : 'a' , supportsDataExplorer : false , type : 'str' , size : 54 , shape : '' , count : 0 , truncated : false } ,
259+ { name : 'strb' , value : 'b' , supportsDataExplorer : false , type : 'str' , size : 54 , shape : '' , count : 0 , truncated : false } ,
260+ { name : 'strc' , value : 'c' , supportsDataExplorer : false , type : 'str' , size : 54 , shape : '' , count : 0 , truncated : false } ,
261+ ] ;
262+ verifyVariables ( wrapper , targetVariables ) ;
263+
264+ sortVariableExplorer ( wrapper , 'value' , 'DESC' ) ;
265+
266+ targetVariables = [
267+ { name : 'strc' , value : 'c' , supportsDataExplorer : false , type : 'str' , size : 54 , shape : '' , count : 0 , truncated : false } ,
268+ { name : 'strb' , value : 'b' , supportsDataExplorer : false , type : 'str' , size : 54 , shape : '' , count : 0 , truncated : false } ,
269+ { name : 'stra' , value : 'a' , supportsDataExplorer : false , type : 'str' , size : 54 , shape : '' , count : 0 , truncated : false } ,
270+ { name : 'c' , value : '3' , supportsDataExplorer : false , type : 'int' , size : 54 , shape : '' , count : 0 , truncated : false } ,
271+ { name : 'b' , value : '2' , supportsDataExplorer : false , type : 'int' , size : 54 , shape : '' , count : 0 , truncated : false } ,
272+ { name : 'a' , value : '1' , supportsDataExplorer : false , type : 'int' , size : 54 , shape : '' , count : 0 , truncated : false } ,
236273 ] ;
237274 verifyVariables ( wrapper , targetVariables ) ;
238275 } , ( ) => { return ioc ; } ) ;
@@ -249,6 +286,16 @@ function openVariableExplorer(wrapper: ReactWrapper<any, Readonly<{}>, React.Com
249286 }
250287}
251288
289+ function sortVariableExplorer ( wrapper : ReactWrapper < any , Readonly < { } > , React . Component > , sortColumn : string , sortDirection : string ) {
290+ const varExp : VariableExplorer = wrapper . find ( 'VariableExplorer' ) . instance ( ) as VariableExplorer ;
291+
292+ assert ( varExp ) ;
293+
294+ if ( varExp ) {
295+ varExp . sortRows ( sortColumn , sortDirection ) ;
296+ }
297+ }
298+
252299// Verify a set of rows versus a set of expected variables
253300function verifyVariables ( wrapper : ReactWrapper < any , Readonly < { } > , React . Component > , targetVariables : IJupyterVariable [ ] ) {
254301 const foundRows = wrapper . find ( 'div.react-grid-Row' ) ;
0 commit comments