/** * External dependencies */ import TestRenderer from 'react-test-renderer'; /** * Internal dependencies */ import withCategory from '../with-category'; import * as mockUtils from '../../components/utils'; import * as mockBaseUtils from '../../base/utils/errors'; jest.mock( '../../components/utils', () => ( { getCategory: jest.fn(), } ) ); jest.mock( '../../base/utils/errors', () => ( { formatError: jest.fn(), } ) ); const mockCategory = { name: 'Clothing' }; const attributes = { categoryId: 1 }; const TestComponent = withCategory( ( props ) => { return (
); } ); const render = () => { return TestRenderer.create( ); }; describe( 'withCategory Component', () => { let renderer; afterEach( () => { mockUtils.getCategory.mockReset(); } ); describe( 'lifecycle events', () => { beforeEach( () => { mockUtils.getCategory.mockImplementation( () => Promise.resolve() ); renderer = render(); } ); it( 'getCategory is called on mount with passed in category id', () => { const { getCategory } = mockUtils; expect( getCategory ).toHaveBeenCalledWith( attributes.categoryId ); expect( getCategory ).toHaveBeenCalledTimes( 1 ); } ); it( 'getCategory is called on component update', () => { const { getCategory } = mockUtils; const newAttributes = { ...attributes, categoryId: 2 }; renderer.update( ); expect( getCategory ).toHaveBeenNthCalledWith( 2, newAttributes.categoryId ); expect( getCategory ).toHaveBeenCalledTimes( 2 ); } ); it( 'getCategory is hooked to the prop', () => { const { getCategory } = mockUtils; const props = renderer.root.findByType( 'div' ).props; props.getCategory(); expect( getCategory ).toHaveBeenCalledTimes( 2 ); } ); } ); describe( 'when the API returns category data', () => { beforeEach( () => { mockUtils.getCategory.mockImplementation( ( categoryId ) => Promise.resolve( { ...mockCategory, id: categoryId } ) ); renderer = render(); } ); it( 'sets the category props', () => { const props = renderer.root.findByType( 'div' ).props; expect( props.error ).toBeNull(); expect( typeof props.getCategory ).toBe( 'function' ); expect( props.isLoading ).toBe( false ); expect( props.category ).toEqual( { ...mockCategory, id: attributes.categoryId, } ); } ); } ); describe( 'when the API returns an error', () => { const error = { message: 'There was an error.' }; const getCategoryPromise = Promise.reject( error ); const formattedError = { message: 'There was an error.', type: 'api' }; beforeEach( () => { mockUtils.getCategory.mockImplementation( () => getCategoryPromise ); mockBaseUtils.formatError.mockImplementation( () => formattedError ); renderer = render(); } ); it( 'sets the error prop', ( done ) => { const { formatError } = mockBaseUtils; getCategoryPromise.catch( () => { const props = renderer.root.findByType( 'div' ).props; expect( formatError ).toHaveBeenCalledWith( error ); expect( formatError ).toHaveBeenCalledTimes( 1 ); expect( props.error ).toEqual( formattedError ); expect( typeof props.getCategory ).toBe( 'function' ); expect( props.isLoading ).toBe( false ); expect( props.category ).toBeNull(); done(); } ); } ); } ); } ); Fantasy Team ( IPL 2023 ) – Page 3 – HOW TO CRIC

Fantasy Team ( IPL 2023 )

RR vs PBKS Dream 11 Team Prediction Today: फेंटेसी क्रिकेट टिप्स, Playing 11, पिच रिपोर्ट मौसम रिपोर्ट और आज के मैच की बेस्ट विनिंग टीम, IPL 2023 Match 8

IPL 2023: RR vs PBKS Dream 11 Team Prediction Today, Match 8, आज होने वाले IPL मैच में कौन जीतेगा? यह जानने के लिए आप इस आर्टिकल पेज पर बने रह सकते हैं| क्योंकि मैं RR ओर PBKS आपको की कुछ ऐसे महत्वपूर्ण बातें बताऊंगा| जिससे कि आप dream11 पर एक बेहतरीन टीम तैयार कर …

RR vs PBKS Dream 11 Team Prediction Today: फेंटेसी क्रिकेट टिप्स, Playing 11, पिच रिपोर्ट मौसम रिपोर्ट और आज के मैच की बेस्ट विनिंग टीम, IPL 2023 Match 8 Read More »

DC (Delhi Captials) vs GT (Gujarat Titans) Dream 11 Team Prediction Today: फेंटेसी क्रिकेट टिप्स, Playing 11, पिच रिपोर्ट मौसम रिपोर्ट और आज के मैच की बेस्ट विनिंग टीम, IPL 2023 Match 7

IPL 2023: DC (Delhi Captials) vs GT (Gujarat Titans) Dream 11 Team Prediction Today, Match 7, आज होने वाले IPL मैच में कौन जीतेगा? यह जानने के लिए आप इस आर्टिकल पेज पर बने रह सकते हैं| क्योंकि मैं आपको दिल्ली कैपिटल्स और गुजरात टाइटंस की कुछ ऐसे महत्वपूर्ण बातें बताऊंगा| जिससे कि आप dream11 …

DC (Delhi Captials) vs GT (Gujarat Titans) Dream 11 Team Prediction Today: फेंटेसी क्रिकेट टिप्स, Playing 11, पिच रिपोर्ट मौसम रिपोर्ट और आज के मैच की बेस्ट विनिंग टीम, IPL 2023 Match 7 Read More »

IPL GT vs CSK Dream 11 Team Prediction Today

GT vs CSK Dream 11 Team Prediction Today: जीते डेढ़ करोड़ फेंटेसी क्रिकेट टिप्स, Playing 11, पिच रिपोर्ट, मौसम रिपोर्ट और आज के मैच की बेस्ट विनिंग टीम GT vs CSK Dream 11 Team Prediction Today: हम बात करने जा रहे हैं, TATA IPL 2023 की जो कि 31 मार्च से शुरू हो रहा है| …

IPL GT vs CSK Dream 11 Team Prediction Today Read More »

ICC ODI रैंकिंग 2023 शीर्ष 10 बल्लेबाज और गेंदबाज टीमों का विवरण | ICC ODI rankings 2023 top 10 Batsman And Bowler details of teams

क्या आपको आईसीसी ओडीआई रैंकिंग 2023 शीर्ष 10 बल्लेबाज गेंदबाज टीमों का विवरण इन सब के बारे में जानना है, तो आज का आर्टिकल इसी टॉपिक से Related जिसमें आपको टॉप 10 बल्लेबाज, टॉप 10 गेंदबाज, टॉप 10 टीमों का विवरण दिया गया है, तो कृपया ध्यानपूर्वक पढ़ें? आईसीसी वनडे रैंकिंग 2023? आईसीसी बल्लेबाजी में …

ICC ODI रैंकिंग 2023 शीर्ष 10 बल्लेबाज और गेंदबाज टीमों का विवरण | ICC ODI rankings 2023 top 10 Batsman And Bowler details of teams Read More »

Scroll to Top