@@ -32,7 +32,7 @@ describe('FieldStatisticService', () => {
3232
3333 //存在对应数据源数据集返回查询结果
3434 it ( 'success:processAsync' , ( done ) => {
35- var fieldStatisticService = new FieldStatisticService ( dataServiceURL , options ) ;
35+ var fieldStatisticService ;
3636 var fieldStatisticCompleted = ( fieldStatisticEventArgsSystem ) => {
3737 try {
3838 expect ( fieldStatisticEventArgsSystem ) . not . toBeNull ( ) ;
@@ -62,7 +62,7 @@ describe('FieldStatisticService', () => {
6262 'processFailed' : fieldStatisticFailed
6363 }
6464 } ;
65-
65+ fieldStatisticService = new FieldStatisticService ( dataServiceURL , options ) ;
6666 expect ( fieldStatisticService ) . not . toBeNull ( ) ;
6767 expect ( fieldStatisticService . url ) . toBe ( dataServiceURL ) ;
6868 fieldStatisticService . dataset = "Countries" ;
@@ -73,13 +73,12 @@ describe('FieldStatisticService', () => {
7373 expect ( testUrl ) . toBe ( dataServiceURL + "/datasources/World/datasets/Countries/fields/SmID/AVERAGE" ) ;
7474 return Promise . resolve ( new Response ( `{"result":124,"mode":"AVERAGE"}` ) ) ;
7575 } ) ;
76- fieldStatisticService . events . on ( { 'processCompleted' : fieldStatisticCompleted } ) ;
7776 fieldStatisticService . processAsync ( ) ;
7877 } ) ;
7978
8079 //错误数据集,查询错误
8180 it ( 'processAsync_datasetsWrong' , ( done ) => {
82- var fieldStatisticService = new FieldStatisticService ( dataServiceURL , options ) ;
81+ var fieldStatisticService ;
8382 var fieldStatisticCompleted = ( fieldStatisticEventArgsSystem ) => {
8483
8584 } ;
@@ -104,6 +103,7 @@ describe('FieldStatisticService', () => {
104103 'processFailed' : fieldStatisticFailed
105104 }
106105 } ;
106+ fieldStatisticService = new FieldStatisticService ( dataServiceURL , options ) ;
107107 fieldStatisticService . dataset = "NoDataset" ;
108108 fieldStatisticService . datasource = "World" ;
109109 fieldStatisticService . field = "NotIDThis" ;
@@ -112,11 +112,10 @@ describe('FieldStatisticService', () => {
112112 expect ( testUrl ) . toBe ( dataServiceURL + "/datasources/World/datasets/NoDataset/fields/NotIDThis/AVERAGE" ) ;
113113 return Promise . resolve ( new Response ( `{"succeed":false,"error":{"code":500,"errorMsg":"抛出未被捕获的异常,错误信息是数据集NoDataset在数据源中不存在"}}` ) ) ;
114114 } ) ;
115- fieldStatisticService . events . on ( { 'processFailed' : fieldStatisticFailed } ) ;
116115 fieldStatisticService . processAsync ( ) ;
117116 } )
118117 it ( 'processAsync_customQueryParam' , ( done ) => {
119- var fieldStatisticService = new FieldStatisticService ( dataServiceURL + '?key=111' , options ) ;
118+ var fieldStatisticService ;
120119 var fieldStatisticCompleted = ( fieldStatisticEventArgsSystem ) => {
121120 try {
122121 fieldStatisticService . destroy ( ) ;
@@ -137,7 +136,7 @@ describe('FieldStatisticService', () => {
137136 'processFailed' : fieldStatisticFailed
138137 }
139138 } ;
140-
139+ fieldStatisticService = new FieldStatisticService ( dataServiceURL + '?key=111' , options )
141140 expect ( fieldStatisticService . url ) . toBe ( dataServiceURL + '?key=111' ) ;
142141 fieldStatisticService . dataset = "Countries" ;
143142 fieldStatisticService . datasource = "World" ;
@@ -147,7 +146,6 @@ describe('FieldStatisticService', () => {
147146 expect ( testUrl ) . toBe ( dataServiceURL + "/datasources/World/datasets/Countries/fields/SmID/AVERAGE?key=111" ) ;
148147 return Promise . resolve ( new Response ( `{"result":124,"mode":"AVERAGE"}` ) ) ;
149148 } ) ;
150- fieldStatisticService . events . on ( { 'processCompleted' : fieldStatisticCompleted } ) ;
151149 fieldStatisticService . processAsync ( ) ;
152150 } ) ;
153151} ) ;
0 commit comments