@@ -708,134 +708,135 @@ describe('query-history', () => {
708708 expect ( historyTreeDataProvider . getChildren ( ) ) . to . deep . eq ( [ mockQuery ] ) ;
709709 expect ( historyTreeDataProvider . getChildren ( mockQuery ) ) . to . deep . eq ( [ ] ) ;
710710 } ) ;
711- } ) ;
712-
713- describe ( 'getChildren' , ( ) => {
714- const history = [
715- item ( 'a' , 2 , 'remote' , 24 ) ,
716- item ( 'b' , 10 , 'local' , 20 ) ,
717- item ( 'c' , 5 , 'local' , 30 ) ,
718- item ( 'd' , 1 , 'local' , 25 ) ,
719- item ( 'e' , 6 , 'remote' , 5 ) ,
720- ] ;
721- let treeDataProvider : HistoryTreeDataProvider ;
722711
723- beforeEach ( async ( ) => {
724- queryHistoryManager = await createMockQueryHistory ( allHistory ) ;
725- ( queryHistoryManager . treeDataProvider as any ) . history = [ ...history ] ;
726- treeDataProvider = queryHistoryManager . treeDataProvider ;
727- } ) ;
712+ describe ( 'getChildren' , ( ) => {
713+ const history = [
714+ item ( 'a' , 2 , 'remote' , 24 ) ,
715+ item ( 'b' , 10 , 'local' , 20 ) ,
716+ item ( 'c' , 5 , 'local' , 30 ) ,
717+ item ( 'd' , 1 , 'local' , 25 ) ,
718+ item ( 'e' , 6 , 'remote' , 5 ) ,
719+ ] ;
720+ let treeDataProvider : HistoryTreeDataProvider ;
721+
722+ beforeEach ( async ( ) => {
723+ queryHistoryManager = await createMockQueryHistory ( allHistory ) ;
724+ ( queryHistoryManager . treeDataProvider as any ) . history = [ ...history ] ;
725+ treeDataProvider = queryHistoryManager . treeDataProvider ;
726+ } ) ;
728727
729- it ( 'should get children for name ascending' , async ( ) => {
730- const expected = [ ...history ] ;
731- treeDataProvider . sortOrder = SortOrder . NameAsc ;
728+ it ( 'should get children for name ascending' , async ( ) => {
729+ const expected = [ ...history ] ;
730+ treeDataProvider . sortOrder = SortOrder . NameAsc ;
732731
733- const children = await treeDataProvider . getChildren ( ) ;
734- expect ( children ) . to . deep . eq ( expected ) ;
735- } ) ;
732+ const children = await treeDataProvider . getChildren ( ) ;
733+ expect ( children ) . to . deep . eq ( expected ) ;
734+ } ) ;
736735
737- it ( 'should get children for name descending' , async ( ) => {
738- const expected = [ ...history ] . reverse ( ) ;
739- treeDataProvider . sortOrder = SortOrder . NameDesc ;
736+ it ( 'should get children for name descending' , async ( ) => {
737+ const expected = [ ...history ] . reverse ( ) ;
738+ treeDataProvider . sortOrder = SortOrder . NameDesc ;
740739
741- const children = await treeDataProvider . getChildren ( ) ;
742- expect ( children ) . to . deep . eq ( expected ) ;
743- } ) ;
740+ const children = await treeDataProvider . getChildren ( ) ;
741+ expect ( children ) . to . deep . eq ( expected ) ;
742+ } ) ;
744743
745- it ( 'should get children for date ascending' , async ( ) => {
746- const expected = [ history [ 3 ] , history [ 0 ] , history [ 2 ] , history [ 4 ] , history [ 1 ] ] ;
747- treeDataProvider . sortOrder = SortOrder . DateAsc ;
744+ it ( 'should get children for date ascending' , async ( ) => {
745+ const expected = [ history [ 3 ] , history [ 0 ] , history [ 2 ] , history [ 4 ] , history [ 1 ] ] ;
746+ treeDataProvider . sortOrder = SortOrder . DateAsc ;
748747
749- const children = await treeDataProvider . getChildren ( ) ;
750- expect ( children ) . to . deep . eq ( expected ) ;
751- } ) ;
748+ const children = await treeDataProvider . getChildren ( ) ;
749+ expect ( children ) . to . deep . eq ( expected ) ;
750+ } ) ;
752751
753- it ( 'should get children for date descending' , async ( ) => {
754- const expected = [ history [ 3 ] , history [ 0 ] , history [ 2 ] , history [ 4 ] , history [ 1 ] ] . reverse ( ) ;
755- treeDataProvider . sortOrder = SortOrder . DateDesc ;
752+ it ( 'should get children for date descending' , async ( ) => {
753+ const expected = [ history [ 3 ] , history [ 0 ] , history [ 2 ] , history [ 4 ] , history [ 1 ] ] . reverse ( ) ;
754+ treeDataProvider . sortOrder = SortOrder . DateDesc ;
756755
757- const children = await treeDataProvider . getChildren ( ) ;
758- expect ( children ) . to . deep . eq ( expected ) ;
759- } ) ;
756+ const children = await treeDataProvider . getChildren ( ) ;
757+ expect ( children ) . to . deep . eq ( expected ) ;
758+ } ) ;
760759
761- it ( 'should get children for result count ascending' , async ( ) => {
762- const expected = [ history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 2 ] ] ;
763- treeDataProvider . sortOrder = SortOrder . CountAsc ;
760+ it ( 'should get children for result count ascending' , async ( ) => {
761+ const expected = [ history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 2 ] ] ;
762+ treeDataProvider . sortOrder = SortOrder . CountAsc ;
764763
765- const children = await treeDataProvider . getChildren ( ) ;
766- expect ( children ) . to . deep . eq ( expected ) ;
767- } ) ;
764+ const children = await treeDataProvider . getChildren ( ) ;
765+ expect ( children ) . to . deep . eq ( expected ) ;
766+ } ) ;
768767
769- it ( 'should get children for result count descending' , async ( ) => {
770- const expected = [ history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 2 ] ] . reverse ( ) ;
771- treeDataProvider . sortOrder = SortOrder . CountDesc ;
768+ it ( 'should get children for result count descending' , async ( ) => {
769+ const expected = [ history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 2 ] ] . reverse ( ) ;
770+ treeDataProvider . sortOrder = SortOrder . CountDesc ;
772771
773- const children = await treeDataProvider . getChildren ( ) ;
774- expect ( children ) . to . deep . eq ( expected ) ;
775- } ) ;
772+ const children = await treeDataProvider . getChildren ( ) ;
773+ expect ( children ) . to . deep . eq ( expected ) ;
774+ } ) ;
776775
777- it ( 'should get children for result count ascending when there are no results' , async ( ) => {
778- // fall back to name
779- const thisHistory = [ item ( 'a' , 10 ) , item ( 'b' , 50 ) , item ( 'c' , 1 ) ] ;
780- ( queryHistoryManager ! . treeDataProvider as any ) . history = [ ...thisHistory ] ;
781- const expected = [ ...thisHistory ] ;
782- treeDataProvider . sortOrder = SortOrder . CountAsc ;
776+ it ( 'should get children for result count ascending when there are no results' , async ( ) => {
777+ // fall back to name
778+ const thisHistory = [ item ( 'a' , 10 ) , item ( 'b' , 50 ) , item ( 'c' , 1 ) ] ;
779+ ( queryHistoryManager ! . treeDataProvider as any ) . history = [ ...thisHistory ] ;
780+ const expected = [ ...thisHistory ] ;
781+ treeDataProvider . sortOrder = SortOrder . CountAsc ;
783782
784- const children = await treeDataProvider . getChildren ( ) ;
785- expect ( children ) . to . deep . eq ( expected ) ;
786- } ) ;
783+ const children = await treeDataProvider . getChildren ( ) ;
784+ expect ( children ) . to . deep . eq ( expected ) ;
785+ } ) ;
787786
788- it ( 'should get children for result count descending when there are no results' , async ( ) => {
789- // fall back to name
790- const thisHistory = [ item ( 'a' , 10 ) , item ( 'b' , 50 ) , item ( 'c' , 1 ) ] ;
791- ( queryHistoryManager ! . treeDataProvider as any ) . history = [ ...thisHistory ] ;
792- const expected = [ ...thisHistory ] . reverse ( ) ;
793- treeDataProvider . sortOrder = SortOrder . CountDesc ;
787+ it ( 'should get children for result count descending when there are no results' , async ( ) => {
788+ // fall back to name
789+ const thisHistory = [ item ( 'a' , 10 ) , item ( 'b' , 50 ) , item ( 'c' , 1 ) ] ;
790+ ( queryHistoryManager ! . treeDataProvider as any ) . history = [ ...thisHistory ] ;
791+ const expected = [ ...thisHistory ] . reverse ( ) ;
792+ treeDataProvider . sortOrder = SortOrder . CountDesc ;
794793
795- const children = await treeDataProvider . getChildren ( ) ;
796- expect ( children ) . to . deep . eq ( expected ) ;
797- } ) ;
794+ const children = await treeDataProvider . getChildren ( ) ;
795+ expect ( children ) . to . deep . eq ( expected ) ;
796+ } ) ;
798797
799- function item ( label : string , start : number , t = 'local' , resultCount ?: number ) {
800- if ( t === 'local' ) {
801- return {
802- getQueryName ( ) {
803- return label ;
804- } ,
805- getQueryFileName ( ) {
806- return label + '.ql' ;
807- } ,
808- initialInfo : {
809- start : new Date ( start ) ,
810- databaseInfo : {
811- name : 'test' ,
812- }
813- } ,
814- completedQuery : {
815- resultCount,
816- } ,
817- t
818- } ;
819- } else {
820- return {
821- status : 'success' ,
822- remoteQuery : {
823- queryFilePath : label + '.ql' ,
824- queryName : label ,
825- executionStartTime : start ,
826- controllerRepository : {
827- name : 'test' ,
828- owner : 'user' ,
798+ function item ( label : string , start : number , t = 'local' , resultCount ?: number ) {
799+ if ( t === 'local' ) {
800+ return {
801+ getQueryName ( ) {
802+ return label ;
829803 } ,
830- repositories : [ ]
831- } ,
832- resultCount,
833- t
834- } ;
804+ getQueryFileName ( ) {
805+ return label + '.ql' ;
806+ } ,
807+ initialInfo : {
808+ start : new Date ( start ) ,
809+ databaseInfo : {
810+ name : 'test' ,
811+ }
812+ } ,
813+ completedQuery : {
814+ resultCount,
815+ } ,
816+ t
817+ } ;
818+ } else {
819+ return {
820+ status : 'success' ,
821+ remoteQuery : {
822+ queryFilePath : label + '.ql' ,
823+ queryName : label ,
824+ executionStartTime : start ,
825+ controllerRepository : {
826+ name : 'test' ,
827+ owner : 'user' ,
828+ } ,
829+ repositories : [ ]
830+ } ,
831+ resultCount,
832+ t
833+ } ;
834+ }
835835 }
836- }
836+ } ) ;
837837 } ) ;
838838
839+
839840 async function createMockQueryHistory ( allHistory : QueryHistoryInfo [ ] ) {
840841 const qhm = new QueryHistoryManager (
841842 { } as QueryRunner ,
0 commit comments