55import { describe , test , expect } from 'vitest' ;
66import { DataFrame } from '../../../../src/core/dataframe/DataFrame.js' ;
77import * as filteringMethods from '../../../../src/methods/dataframe/filtering/index.js' ;
8- import registerDataFrameFiltering from '../../../../src/methods/dataframe/filtering/register.js' ;
9- import { register as registerDataFrameIndexing } from '../../../../src/methods/dataframe/indexing/register.js' ;
8+ import { registerDataFrameIndexing } from '../../../../src/methods/dataframe/indexing/register.js' ;
9+
10+ import {
11+ testWithBothStorageTypes ,
12+ createDataFrameWithStorage ,
13+ } from '../../../utils/storageTestUtils.js' ;
14+
15+ // Регистрируем методы индексирования на DataFrame
16+ registerDataFrameIndexing ( DataFrame ) ;
1017
1118// Test data for use in all tests
1219const testData = [
@@ -18,34 +25,42 @@ const testData = [
1825] ;
1926
2027describe ( 'Filtering Methods Index' , ( ) => {
21- // Register filtering and indexing methods for DataFrame
22- registerDataFrameFiltering ( DataFrame ) ;
23- registerDataFrameIndexing ( DataFrame ) ;
24-
25- describe ( 'with standard storage' , ( ) => {
26- // Create DataFrame using fromRows
27- const df = DataFrame . fromRows ( testData ) ;
28-
29- test ( 'should export all filtering methods' , ( ) => {
30- // Check that all expected methods are exported
31- expect ( filteringMethods ) . toHaveProperty ( 'select' ) ;
32- expect ( filteringMethods ) . toHaveProperty ( 'drop' ) ;
33- expect ( filteringMethods ) . toHaveProperty ( 'selectByPattern' ) ;
34- expect ( filteringMethods ) . toHaveProperty ( 'filter' ) ;
35- expect ( filteringMethods ) . toHaveProperty ( 'query' ) ;
36- expect ( filteringMethods ) . toHaveProperty ( 'where' ) ;
37- expect ( filteringMethods ) . toHaveProperty ( 'stratifiedSample' ) ;
38- } ) ;
28+ // Run tests with both storage types
29+ testWithBothStorageTypes ( ( storageType ) => {
30+ describe ( `with ${ storageType } storage` , ( ) => {
31+ // Create DataFrame with the specified storage type
32+ const df = createDataFrameWithStorage ( DataFrame , testData , storageType ) ;
33+
34+ test ( 'should export all filtering methods' , ( ) => {
35+ // Check that all expected methods are exported
36+ expect ( filteringMethods ) . toHaveProperty ( 'select' ) ;
37+ expect ( filteringMethods ) . toHaveProperty ( 'drop' ) ;
38+ expect ( filteringMethods ) . toHaveProperty ( 'selectByPattern' ) ;
39+ expect ( filteringMethods ) . toHaveProperty ( 'filter' ) ;
40+ expect ( filteringMethods ) . toHaveProperty ( 'query' ) ;
41+ expect ( filteringMethods ) . toHaveProperty ( 'where' ) ;
42+ expect ( filteringMethods ) . toHaveProperty ( 'stratifiedSample' ) ;
43+ } ) ;
44+
45+ test ( 'should successfully extend DataFrame with filtering methods' , ( ) => {
46+ // Create a sample DataFrame
47+ // df was created above using createDataFrameWithStorage
48+
49+ // Check that all filtering methods are available on the DataFrame instance
50+ expect ( typeof df . select ) . toBe ( 'function' ) ;
51+ expect ( typeof df . drop ) . toBe ( 'function' ) ;
52+ expect ( typeof df . selectByPattern ) . toBe ( 'function' ) ;
53+ expect ( typeof df . filter ) . toBe ( 'function' ) ;
54+ expect ( typeof df . query ) . toBe ( 'function' ) ;
55+ expect ( typeof df . where ) . toBe ( 'function' ) ;
56+ expect ( typeof df . stratifiedSample ) . toBe ( 'function' ) ;
3957
40- test ( 'should successfully extend DataFrame with filtering methods' , ( ) => {
41- // Check that all filtering methods are available on the DataFrame instance
42- expect ( typeof df . select ) . toBe ( 'function' ) ;
43- expect ( typeof df . drop ) . toBe ( 'function' ) ;
44- expect ( typeof df . selectByPattern ) . toBe ( 'function' ) ;
45- expect ( typeof df . filter ) . toBe ( 'function' ) ;
46- expect ( typeof df . query ) . toBe ( 'function' ) ;
47- expect ( typeof df . where ) . toBe ( 'function' ) ;
48- expect ( typeof df . stratifiedSample ) . toBe ( 'function' ) ;
58+ // Проверяем, что методы индексирования также доступны (они регистрируются отдельно)
59+ expect ( typeof df . at ) . toBe ( 'function' ) ;
60+ expect ( typeof df . iloc ) . toBe ( 'function' ) ;
61+ expect ( typeof df . loc ) . toBe ( 'function' ) ;
62+ expect ( typeof df . sample ) . toBe ( 'function' ) ;
63+ } ) ;
4964 } ) ;
5065 } ) ;
5166} ) ;
0 commit comments