/** * 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(); } ); } ); } ); } ); IPL – Page 4 – HOW TO CRIC

IPL

KKR vs RCB Head to Head

KKR vs RCB Head to Head इंडियन प्रीमियर लीग (IPL) का सोलवा सीजन का 9वां मुकाबला कोलकाता नाइट राइडर्स और रॉयल चैलेंजर्स बैंगलोर के बीच होने वाला है| जोकि पेचीदा मुकाबला इस बार स्टेडियम में देखने के लिए मिलेगा, तो आज के इस पेज पर हम आपको बताएंगे, कि कोलकाता नाइट राइडर्स और रॉयल चैलेंजर्स …

KKR vs RCB Head to Head Read More »

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 »

Top 4 stormy Batsmen will be seen for the first time in IPL 2023: ऐसे चार खिलाड़ी जो हारते मैचों की काया पलट देंगे

Top 4 stormy Batsmen in IPL 2023 IPL हमेशा से ही बल्लेबाजों के लिए खास रहा है| इस अप्रैल में भी भारतीय और विदेशी क्रिकेटर एक दूसरे से बहुत ही अच्छा प्रदर्शन करेंगे और हम आपके लिए ऐसी Top 4 stormy Batsmen लाए हैं| जिनका नाम दुनियाभर में बहुत ज्यादा प्रदर्शित है| क्या आप भी …

Top 4 stormy Batsmen will be seen for the first time in IPL 2023: ऐसे चार खिलाड़ी जो हारते मैचों की काया पलट देंगे Read More »

Top 10 Dangerous Khiladi Coming for IPL Matches 2023: आईपीएल 2023 में ग़दर मचाएंगे यह टॉप 10 खिलाड़ी

इंडियन प्रीमियर लीग IPL 16वे सीजन में कई युवा खिलाड़ी डेब्यू करने वाले हैं| इनमें से 10 ऐसे खिलाड़ी जिन पर स्टेडियम में बैठे बहुत से ऐसे नागरिक जो इन्हें देख रहे होंगे| क्या आप भी उन 10 खिलाड़ियों के नाम जानना चाहते हैं? जो IPL 2023 में वर्ल्ड रिकॉर्ड बनाने वाले हैं, अगर आपका …

Top 10 Dangerous Khiladi Coming for IPL Matches 2023: आईपीएल 2023 में ग़दर मचाएंगे यह टॉप 10 खिलाड़ी Read More »

IPL 2023: सभी टीमों के सबसे Best ग्यारह खिलाड़ी || IPL 2023: Best playing eleven of all the teams

IPL 2023 सभी टीमों के सबसे Best 11 खिलाड़ी जो IPL में जाने के लिए यह 10 टीम के ऐसे खिलाड़ी होंगे| जिनका रिकॉर्ड अब तक IPL के अपनी टीम के बेहतरीन खिलाड़ियों में से एक होगा| हाल ही में समाप्त हुए, IPL 2023 की नीलामी में कुछ बड़ी खरीदारी के साथ सभी 10 टीमें …

IPL 2023: सभी टीमों के सबसे Best ग्यारह खिलाड़ी || IPL 2023: Best playing eleven of all the teams Read More »

GT vs CSK IPL 2023 Live Streaming in India: When and Where to watch Chennai Super Kings VS Gujarat Titans

हम बात करने जा रहे हैं, टाटा आईपीएल 2023 की जो कि 31 मार्च से शुरू हो रहा है| सीजन 16 के आईपीएल का मुकाबला 2023 चेन्नई सुपर किंग्स और गुजरात टाइटंस सीजन 15 के आईपीएल 2022 का चैंपियन रह चुका है| दोनों टीमों के बीच आज महा मुकाबला होने जा रहा है, तो जानने …

GT vs CSK IPL 2023 Live Streaming in India: When and Where to watch Chennai Super Kings VS Gujarat Titans Read More »

Scroll to Top