@@ -11,7 +11,7 @@ import {
11
11
DataGroup
12
12
} from '../src/data/aggr_structures' ;
13
13
14
- // Тесты для AggregationColumnStore
14
+ // Tests for AggregationColumnStore
15
15
describe ( 'AggregationColumnStore Interface' , ( ) => {
16
16
let columnStore : AggregationColumnStore ;
17
17
@@ -35,30 +35,30 @@ describe('AggregationColumnStore Interface', () => {
35
35
} ;
36
36
} ) ;
37
37
38
- it ( 'должен возвращать массив идентификаторов колонок в указанном диапазоне ' , ( ) => {
38
+ it ( 'should return an array of column identifiers in specified range ' , ( ) => {
39
39
const columns = columnStore . getColumnIds ( 1 , 3 ) ;
40
40
expect ( columns ) . toBeArrayEqual ( [ 'col1' , 'col2' , 'col3' ] ) ;
41
41
} ) ;
42
42
43
- it ( 'должен возвращать один идентификатор колонки, если указан только начальный индекс ' , ( ) => {
43
+ it ( 'should return a single column identifier if only starting index is specified ' , ( ) => {
44
44
const columns = columnStore . getColumnIds ( 5 ) ;
45
45
expect ( columns ) . toBeArrayEqual ( [ 'col5' ] ) ;
46
46
} ) ;
47
47
48
- it ( 'должен проверять валидность колонок ' , ( ) => {
48
+ it ( 'should check the column validity ' , ( ) => {
49
49
expect ( columnStore . validateColumns ( [ 'col1' , 'col2' ] ) ) . toBe ( true ) ;
50
50
expect ( columnStore . validateColumns ( [ 'col1' , 'invalid' ] ) ) . toBe ( false ) ;
51
51
} ) ;
52
52
53
- it ( 'должен проверять валидность агрегатной функции для колонки ' , ( ) => {
53
+ it ( 'should check the aggregate function validity for column ' , ( ) => {
54
54
expect ( columnStore . validateAggregate ( 'col1' , 'sum' ) ) . toBe ( true ) ;
55
55
expect ( columnStore . validateAggregate ( 'col2' , 'avg' ) ) . toBe ( true ) ;
56
56
expect ( columnStore . validateAggregate ( 'col3' , 'invalid' ) ) . toBe ( false ) ;
57
57
expect ( columnStore . validateAggregate ( 'invalid' , 'sum' ) ) . toBe ( false ) ;
58
58
} ) ;
59
59
} ) ;
60
60
61
- // Тесты для AggregatesContainer
61
+ // Tests for AggregatesContainer
62
62
describe ( 'AggregatesContainer Interface' , ( ) => {
63
63
let container : AggregatesContainer ;
64
64
@@ -89,27 +89,27 @@ describe('AggregatesContainer Interface', () => {
89
89
} ;
90
90
} ) ;
91
91
92
- it ( 'должен сохранять данные агрегации для определенного уровня ' , ( ) => {
92
+ it ( 'should save aggregate data for a specific level ' , ( ) => {
93
93
const data = new Map < string , GroupTotals > ( ) ;
94
94
data . set ( JSON . stringify ( { col1 : 'value1' } ) , { sum : 100 , count : 10 } ) ;
95
95
96
96
container . setAggregateData ( 1 , data ) ;
97
-
98
- // Проверим через getAggregateData
97
+
98
+ // Check this through getAggregateData
99
99
return container . getAggregateData ( 1 , { col1 : 'value1' } )
100
100
. then ( totals => {
101
101
expect ( totals ) . toBeObject ( { sum : 100 , count : 10 } ) ;
102
102
} ) ;
103
103
} ) ;
104
104
105
- it ( 'должен возвращать пустой объект для несуществующего уровня ' , ( ) => {
105
+ it ( 'should return an empty object for a non-existent level ' , ( ) => {
106
106
return container . getAggregateData ( 999 , { col1 : 'value1' } )
107
107
. then ( totals => {
108
108
expect ( totals ) . toBeObject ( { } ) ;
109
109
} ) ;
110
110
} ) ;
111
111
112
- it ( 'должен обновлять данные агрегации ' , ( ) => {
112
+ it ( 'should update aggregate data ' , ( ) => {
113
113
container . updateAggregateData ( 1 , { col1 : 'value1' } , { sum : 100 } ) ;
114
114
container . updateAggregateData ( 1 , { col1 : 'value1' } , { sum : 200 } ) ;
115
115
@@ -119,7 +119,7 @@ describe('AggregatesContainer Interface', () => {
119
119
} ) ;
120
120
} ) ;
121
121
122
- it ( 'должен создавать новый уровень при обновлении данных несуществующего уровня ' , ( ) => {
122
+ it ( 'should create a new level when updating data for a non-existent level ' , ( ) => {
123
123
container . updateAggregateData ( 2 , { col2 : 'value2' } , { avg : 50 } ) ;
124
124
125
125
return container . getAggregateData ( 2 , { col2 : 'value2' } )
@@ -129,14 +129,14 @@ describe('AggregatesContainer Interface', () => {
129
129
} ) ;
130
130
} ) ;
131
131
132
- // Тесты для AggregatesCalculator
132
+ // Tests for AggregatesCalculator
133
133
describe ( 'AggregatesCalculator Interface' , ( ) => {
134
134
let container : AggregatesContainer ;
135
135
let calculator : AggregatesCalculator ;
136
136
let needRecalculationValue : boolean ;
137
137
138
138
beforeEach ( ( ) => {
139
- // Создаем мок для AggregatesContainer
139
+ // Create mock for AggregatesContainer
140
140
container = {
141
141
setAggregateData : mock ( ) ,
142
142
getAggregateData : mock ( ) . mockImplementation ( async ( ) => ( { } ) ) ,
@@ -145,7 +145,7 @@ describe('AggregatesCalculator Interface', () => {
145
145
146
146
needRecalculationValue = true ;
147
147
148
- // Создаем мок для AggregatesCalculator
148
+ // Create a mock for AggregatesCalculator
149
149
calculator = {
150
150
getAggrContainer : ( ) => container ,
151
151
@@ -160,7 +160,7 @@ describe('AggregatesCalculator Interface', () => {
160
160
throw error ;
161
161
}
162
162
163
- // Симулируем вычисление и получение результата
163
+ // Simulate calculation and obtaining result
164
164
const result = { sum : 100 , count : 10 } ;
165
165
if ( options ?. resultObtained ) {
166
166
options . resultObtained ( result , 1 ) ;
@@ -177,12 +177,12 @@ describe('AggregatesCalculator Interface', () => {
177
177
} ;
178
178
} ) ;
179
179
180
- it ( 'должен возвращать контейнер агрегатов ' , ( ) => {
180
+ it ( 'should return an aggregate container ' , ( ) => {
181
181
const result = calculator . getAggrContainer ( ) ;
182
182
expect ( result ) . toBe ( container ) ;
183
183
} ) ;
184
184
185
- it ( 'должен выполнять вычисление с вызовом callback-функций ' , async ( ) => {
185
+ it ( 'should perform a calculation with callback functions ' , async ( ) => {
186
186
const resultCallback = mock ( ) ;
187
187
const errorCallback = mock ( ) ;
188
188
@@ -196,7 +196,7 @@ describe('AggregatesCalculator Interface', () => {
196
196
expect ( calculator . needRecalculation ( ) ) . toBe ( false ) ;
197
197
} ) ;
198
198
199
- it ( 'должен вызывать errorOccurred при ошибке вычисления ' , async ( ) => {
199
+ it ( 'should call the errorOccurred on calculation error ' , async ( ) => {
200
200
const resultCallback = mock ( ) ;
201
201
const errorCallback = mock ( ) ;
202
202
@@ -207,7 +207,7 @@ describe('AggregatesCalculator Interface', () => {
207
207
errorOccurred : errorCallback
208
208
} ) ;
209
209
} catch ( error ) {
210
- // Ожидаем, что ошибка будет перехвачена
210
+ // Expect the error to be caught
211
211
}
212
212
213
213
expect ( resultCallback ) . not . toHaveBeenCalled ( ) ;
@@ -217,20 +217,20 @@ describe('AggregatesCalculator Interface', () => {
217
217
expect ( error . level ) . toBe ( 0 ) ;
218
218
} ) ;
219
219
220
- it ( 'должен возвращать needRecalculation=true после reset' , ( ) => {
220
+ it ( 'should return needRecalculation=true after reset' , ( ) => {
221
221
calculator . reset ( ) ;
222
222
expect ( calculator . needRecalculation ( ) ) . toBe ( true ) ;
223
223
} ) ;
224
224
225
- it ( 'должен возвращать needRecalculation=false после успешного вычисления ' , async ( ) => {
225
+ it ( 'should return needRecalculation=false after successful calculation ' , async ( ) => {
226
226
await calculator . calculate ( ) ;
227
227
expect ( calculator . needRecalculation ( ) ) . toBe ( false ) ;
228
228
} ) ;
229
229
} ) ;
230
230
231
- // Тесты для структур данных
231
+ // Tests for data structures
232
232
describe ( 'Data Structures' , ( ) => {
233
- it ( 'должен правильно определять DataGroup' , ( ) => {
233
+ it ( 'should correctly define a DataGroup' , ( ) => {
234
234
const group : DataGroup = {
235
235
name : 'TestGroup' ,
236
236
columns : [ 'col1' , 'col2' ]
@@ -240,7 +240,7 @@ describe('Data Structures', () => {
240
240
expect ( group . columns ) . toBeArrayEqual ( [ 'col1' , 'col2' ] ) ;
241
241
} ) ;
242
242
243
- it ( 'должен работать с GroupKey как с объектом ' , ( ) => {
243
+ it ( 'should work with GroupKey as an object ' , ( ) => {
244
244
const key : GroupKey = {
245
245
col1 : 'value1' ,
246
246
col2 : 100
@@ -249,8 +249,8 @@ describe('Data Structures', () => {
249
249
expect ( key . col1 ) . toBe ( 'value1' ) ;
250
250
expect ( key . col2 ) . toBe ( 100 ) ;
251
251
} ) ;
252
-
253
- it ( 'должен работать с GroupTotals как с объектом ' , ( ) => {
252
+
253
+ it ( 'should work with GroupTotals as an object ' , ( ) => {
254
254
const totals : GroupTotals = {
255
255
sum : 500 ,
256
256
avg : 100 ,
@@ -262,15 +262,15 @@ describe('Data Structures', () => {
262
262
expect ( totals . count ) . toBe ( 5 ) ;
263
263
} ) ;
264
264
265
- it ( 'должен создавать AggrCalculationError с уровнем ' , ( ) => {
265
+ it ( 'should create an AggrCalculationError with a level ' , ( ) => {
266
266
const error = new Error ( 'Test error' ) as AggrCalculationError ;
267
267
error . level = 2 ;
268
268
269
269
expect ( error . message ) . toBe ( 'Test error' ) ;
270
270
expect ( error . level ) . toBe ( 2 ) ;
271
271
} ) ;
272
272
273
- it ( 'должен создавать AggrCalculationOptions с опциями ' , ( ) => {
273
+ it ( 'should create an AggrCalculationOptions with options ' , ( ) => {
274
274
const options : AggrCalculationOptions = {
275
275
maxLevel : 3 ,
276
276
resultObtained : mock ( ) ,
0 commit comments