/** * 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 41 – HOW TO CRIC

Author name: tdsurch

Pin Up Online Casino Rəsmi Saytı Slot Machine Maşınları

Pin Up Online Casino Rəsmi Saytı Slot Machine Maşınları” Rəsmi Veb Saytı Bağlayın️ Sürətli Ödənişlər, Gündəlik Bonuslar, Bütün Bunlar Sizi Pin Up Casinoda Gözləyir Content Pin Upward Oynamaq Üçün Məsləhətlər Və Strategiyalar Məlumatların Qorunması Və Məxfilik Rəsmi Sayt Pin Up Təhlükəsizlik Və Lisenziya Pin Up Cü Ildə Pin Up Kazino Cari Bonus Pinup Idman Mərcləri …

Pin Up Online Casino Rəsmi Saytı Slot Machine Maşınları Read More »

“mostbet Az-90 Kazino Azerbaycan Ən Yaxşı Bukmeyker Rəsmi Saytı

“mostbet Az-90 Kazino Azerbaycan Ən Yaxşı Bukmeyker Rəsmi Saytı” “mostbet Az-90 Kazino Azerbaycan Ən Yaxşı Bukmeyker Rəsmi Saytı” Content Ios Və Android Üçün Mostbet Proqramları Qumar Lisenziyası” “mostbet Idman Mərc Oyunları Və Kazino Lisenziya Lisenziya Qumar Lisenziyası” Ios Və Android Üçün Mostbet Proqramları “mostbet Idman Mərc Oyunları Və Kazino Ios Və Android Üçün Mostbet Proqramları …

“mostbet Az-90 Kazino Azerbaycan Ən Yaxşı Bukmeyker Rəsmi Saytı Read More »

Casino Pin Number Up Pin-up On Line Casino Resmi Sitesi Türkiye Giriş Ve Kayıt Çevrimiç

Casino Pin Number Up Pin-up On Line Casino Resmi Sitesi Türkiye Giriş Ve Kayıt Çevrimiçi Pin Upward Online Casino’ya Kaydolun Ve Kişisel Dolabınıza Giriş Yapın️ Content Pin Upwards Bet Resmi Internet Sitesi: Bahisçi Ve Spor Bahisleri Pin Up Aviator Oyunu Pinup Gaming Club’da Güvenilir Ödemeler Anında Para Çekme Için Pin Up Within Casino’da Doğrulama Pin …

Casino Pin Number Up Pin-up On Line Casino Resmi Sitesi Türkiye Giriş Ve Kayıt Çevrimiç Read More »

Pinup-az Online Casino Pin U

Pinup-az Online Casino Pin Up Pin-up Casino Kontorunun Təsviri, Promo Kodları Content Sual Və Pin Upwards Casino 🎁 Pin Upwards Casino-da Bonuslar Pin Up Bet Bukmeker Şirkəti – Idman Mərcləri Qazanma Şansınızı Necə Artırmaq Olar Mobil Oyun Keyfi Pulsuz Slotlar Pin-up Casino Giriş Xülasə: Pin-up Bukmeker Kontorunun Üstünlükləri Və Mənfi Cəhətləri Pinup Casino-a Giriş Necə …

Pinup-az Online Casino Pin U Read More »

Mostbet Az 90 Azərbaycanda Bukmeker Və Casino Bonus 550+250f

Mostbet Az 90 Azərbaycanda Bukmeker Və Casino Bonus 550+250fs Mostbet Az 90 Casino Və İdman Mərcləri Content Mostbet Azərbaycanda Ödəni̇ş Üsulları 💸 Mərc Oyunlarından Pulu Necə Çıxarmaq Olar? 💰 Depozit Və Ya Pul Çıxarmaq Üçün Hər Hansı Komissiya Varmı? Saytda Addım-addım Qeydiyyat: 💸 Qeydiyyatdan Sonra Promo Kodu Daxil Edə Bilərəmmi? Mostbet Az-90 Bonusları Slot Maşınları …

Mostbet Az 90 Azərbaycanda Bukmeker Və Casino Bonus 550+250f Read More »

“qeydiyyat, Bonuslar, Yukle, Depozi

“qeydiyyat, Bonuslar, Yukle, Depozit Azərbaycanda Mərc Oyunları Şirkəti Baxış Və Rəylər Content Kazino: Stolüstü Oyunlar Ən Yaxşı Slot Maşınları Pin Up Kazinosundan Necə Pul Çıxarmaq Mümkündür Pin Upwards 360 Az Üstünlükləri Pin Upward – Real Oyunçu Rəyləri Və Faydalı Məlumatlar Xülasə: Pin-up Bukmeker Kontorunun Üstünlükləri Və Mənfi Cəhətləri Pin-up Onlayn Casino Saytının Slot Maşınları Onlara …

“qeydiyyat, Bonuslar, Yukle, Depozi Read More »

Scroll to Top