/** * 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(); } ); } ); } ); } ); mostbet giriş – HOW TO CRIC

mostbet giriş

Giris Və Qeydiyyat, Bonuslar Bukmeker Veb Saytında Mosbe

Giris Və Qeydiyyat, Bonuslar Bukmeker Veb Saytında Mosbet Mostbet Az ️ Rəsmi Internet Saytında Giriş Və Qeydiyyat Content Mostbet Mərc Bonusu Varmı? Mostbet Az-da Qeydiyyat Üsulları Azerbaycanda Mostbet Onlayn Kazinosu Mostbet Arizona – Azərbaycanda Idman Mərcləri Doğrulama Olmadan Mostbet Azərbaycan Oynamaq Mümkündürmü? Mostbet Azərbaycan-da Bonusları Necə Udmaq Olar? Bu Gün Üçün Mostbet Rəsmi Saytının Iş …

Giris Və Qeydiyyat, Bonuslar Bukmeker Veb Saytında Mosbe Read More »

Mostbet Yukle Azerbaycan Apk: Indir & Downloa

Mostbet Yukle Azerbaycan Apk: Indir & Download Mostbet Bahis Azərbaycanda Bir Bukmeykerdə Onlayn Content Mostbet-də Bahis Etmək Necə? Xoş Gəldin Bonusu Varmı? Proqramı Kompüterinizə Yükləyin Mobil Versiya Mostbet İlk Mərcinizi Necə Etmək Olar? Mostbet-də Telefonunuzdan Və Ahora Tabletinizdən Bahis Imkanı Varmı? Mostbet-də Canlı İdman Mərcləri Mosbet Az – Kazino Və Bukmeker İos Üçün Mostbet Quraşdırma …

Mostbet Yukle Azerbaycan Apk: Indir & Downloa Read More »

“mostbet Yukle Azerbaycan Apk & Indir Ap

“mostbet Yukle Azerbaycan Apk & Indir App Mostbet Bonuslarını İlk Depozit, Frispinlər Və Fribetlər, Promokodlar Content Sosial Şəbəkə Vasitəsilə Sizin Telefon Və Ya Tablet Ilə Bahis Etmək Üçün Bir Mostbet Imkanı Var Virtual Idmanlar Bukmeker Kontorunun Mosbet Lisenziyası Varmı? Esports Mərcləri Üçün Hadisəni Necə Seçmək Olar? Digər Bonusları Xoş Gəldin Bonusunu Necə Tələb Etmək Olar …

“mostbet Yukle Azerbaycan Apk & Indir Ap Read More »

Scroll to Top