import mockTransformListRow from './__mocks__/transform_list_row.json' ; import mockTransformStats from './__mocks__/transform_stats.json' ; import { TransformListRow } from './transform_list' ; import { getTransformProgress , isCompletedBatchTransform } from './transform_stats' ; const getRow = ( statsId ) => { return { ... ( mockTransformListRow as TransformListRow ) , stats : { ... ( mockTransformStats . transforms as Array < TransformListRow [ 'stats' ] > ) . find ( ( stats ) => stats . id === statsId ) ! , } , } ; } ; describe ( 'Transform: Transform stats.' , ( ) => { test ( 'getTransformProgress()' , ( ) => { expect ( getTransformProgress ( getRow ( 'transform-created' ) ) ) . toBe ( undefined ) ; expect ( getTransformProgress ( getRow ( 'transform-created-started-stopped' ) ) ) . toBe ( undefined ) ; expect ( getTransformProgress ( getRow ( 'transform-running' ) ) ) . toBe ( 21 ) ; expect ( getTransformProgress ( getRow ( 'transform-completed' ) ) ) . toBe ( 100 ) ; } ) ; test ( 'isCompletedBatchTransform()' , ( ) => { expect ( isCompletedBatchTransform ( getRow ( 'transform-created' ) ) ) . toBe ( false ) ; expect ( isCompletedBatchTransform ( getRow ( 'transform-created-started-stopped' ) ) ) . toBe ( false ) ; expect ( isCompletedBatchTransform ( getRow ( 'transform-running' ) ) ) . toBe ( false ) ; expect ( isCompletedBatchTransform ( getRow ( 'transform-completed' ) ) ) . toBe ( true ) ; } ) ; } ) ;