Fix error on dashboard. (https://github.com/woocommerce/woocommerce-admin/pull/1121)
* Fix error on dashboard. * Revert changes from woocommerce/woocommerce-admin#1101
This commit is contained in:
parent
600cfd899a
commit
3c2cdc4322
|
@ -123,7 +123,7 @@ export class TopSellingProducts extends Component {
|
|||
|
||||
export default compose(
|
||||
withSelect( select => {
|
||||
const { getReportStats, getReportStatsError, isReportStatsRequesting } = select( 'wc-admin' );
|
||||
const { getReportStats, isReportStatsRequesting, isReportStatsError } = select( 'wc-admin' );
|
||||
const endpoint = NAMESPACE + 'reports/products';
|
||||
// @TODO We will need to add the date parameters from the Date Picker
|
||||
// { after: '2018-04-22', before: '2018-05-06' }
|
||||
|
@ -131,7 +131,7 @@ export default compose(
|
|||
|
||||
const stats = getReportStats( endpoint, query );
|
||||
const isRequesting = isReportStatsRequesting( endpoint, query );
|
||||
const isError = Boolean( getReportStatsError( endpoint, query ) );
|
||||
const isError = isReportStatsError( endpoint, query );
|
||||
|
||||
return { data: get( stats, 'data', [] ), isRequesting, isError };
|
||||
} )
|
||||
|
|
|
@ -50,14 +50,14 @@ describe( 'TopSellingProducts', () => {
|
|||
test( 'should load report stats from API', () => {
|
||||
const getReportStatsMock = jest.fn().mockReturnValue( { data: mockData } );
|
||||
const isReportStatsRequestingMock = jest.fn().mockReturnValue( false );
|
||||
const getReportStatsErrorMock = jest.fn().mockReturnValue( undefined );
|
||||
const isReportStatsErrorMock = jest.fn().mockReturnValue( false );
|
||||
const registry = createRegistry();
|
||||
registry.registerStore( 'wc-admin', {
|
||||
reducer: () => {},
|
||||
selectors: {
|
||||
getReportStats: getReportStatsMock,
|
||||
isReportStatsRequesting: isReportStatsRequestingMock,
|
||||
getReportStatsError: getReportStatsErrorMock,
|
||||
isReportStatsError: isReportStatsErrorMock,
|
||||
},
|
||||
} );
|
||||
const topSellingProductsWrapper = TestRenderer.create(
|
||||
|
@ -74,8 +74,8 @@ describe( 'TopSellingProducts', () => {
|
|||
expect( getReportStatsMock.mock.calls[ 0 ][ 2 ] ).toEqual( query );
|
||||
expect( isReportStatsRequestingMock.mock.calls[ 0 ][ 1 ] ).toBe( endpoint );
|
||||
expect( isReportStatsRequestingMock.mock.calls[ 0 ][ 2 ] ).toEqual( query );
|
||||
expect( getReportStatsErrorMock.mock.calls[ 0 ][ 1 ] ).toBe( endpoint );
|
||||
expect( getReportStatsErrorMock.mock.calls[ 0 ][ 2 ] ).toEqual( query );
|
||||
expect( isReportStatsErrorMock.mock.calls[ 0 ][ 1 ] ).toBe( endpoint );
|
||||
expect( isReportStatsErrorMock.mock.calls[ 0 ][ 2 ] ).toEqual( query );
|
||||
expect( topSellingProducts.props.data ).toBe( mockData );
|
||||
} );
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue