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

Author name: tdsurch

KKR vs RCB Dream 11 Team Prediction Today

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

KKR vs RCB Dream 11 Team Prediction Today Read More »

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 »

ICC world Cup Super League: 7 टीमों ने वर्ल्ड कप का टिकट कटाया, 3 पर बाहर होने का खतरा मंडराया वर्ल्ड कप सुपर लीग में हुआ बहुत बड़ा बदलाव

जैसा कि सभी जानते हैं, ICC वर्ल्ड कप सुपर लीग में 10 टीम का चयन हो चुका थी| लेकिन सूत्रों के अनुसार, बहुत बड़ा बदलाव देखने के लिए मिला है| 7 टीमों ने वर्ल्ड कप का टिकट कटाया, 3 पर बाहर होने का खतरा मंडराया| जिस तरह हमें खबर मिली है, की तीन टीमों को …

ICC world Cup Super League: 7 टीमों ने वर्ल्ड कप का टिकट कटाया, 3 पर बाहर होने का खतरा मंडराया वर्ल्ड कप सुपर लीग में हुआ बहुत बड़ा बदलाव 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 »

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 »

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 »

Scroll to Top