import { getAnalysisType , getValuesFromResponse , isOutlierAnalysis } from './analytics' ; describe ( 'Data Frame Analytics: Analytics utils' , ( ) => { test ( 'getAnalysisType()' , ( ) => { const outlierAnalysis = { outlier_detection : { } } ; expect ( getAnalysisType ( outlierAnalysis ) ) . toBe ( 'outlier_detection' ) ; const regressionAnalysis = { regression : { } } ; expect ( getAnalysisType ( regressionAnalysis ) ) . toBe ( 'regression' ) ; const otherAnalysis = { other : { } } ; expect ( getAnalysisType ( otherAnalysis ) ) . toBe ( 'other' ) ; const unknownAnalysis = { outlier_detection : { } , regression : { } } ; expect ( getAnalysisType ( unknownAnalysis ) ) . toBe ( 'unknown' ) ; } ) ; test ( 'isOutlierAnalysis()' , ( ) => { const outlierAnalysis = { outlier_detection : { } } ; expect ( isOutlierAnalysis ( outlierAnalysis ) ) . toBe ( true ) ; const regressionAnalysis = { regression : { } } ; expect ( isOutlierAnalysis ( regressionAnalysis ) ) . toBe ( false ) ; const unknownAnalysis = { outlier_detection : { } , regression : { } } ; expect ( isOutlierAnalysis ( unknownAnalysis ) ) . toBe ( false ) ; } ) ; test ( 'getValuesFromResponse()' , ( ) => { const evalResponse = { regression : { huber : { value : 'NaN' } , mse : { value : 7.514953437693147 } , msle : { value : 'Infinity' } , r_squared : { value : 0.9837343227799651 } , } , } ; const expectedResponse = { mse : 7.51 , msle : 'Infinity' , huber : 'NaN' , r_squared : 0.984 , } ; expect ( getValuesFromResponse ( evalResponse ) ) . toEqual ( expectedResponse ) ; } ) ; } ) ;