UNPKG

principles-ui-components

Version:

Supporting UI controller for Tizen TV web application, which developed base on React Framework.

42 lines (29 loc) 1.32 kB
import React, { Component }from 'react'; import {shallow, mount} from 'enzyme'; import Loading from '../UI_Component/Loading'; jest.useFakeTimers(); describe ('<Loading />', () => { it ('Loading unit test, reset props, and calls react lifecicle function', () => { const loadingWrapper = mount(<Loading />); expect(loadingWrapper.props().size).toEqual('L'); jest.runTimersToTime(3000); loadingWrapper.setState({index: 20, display: false}); expect(loadingWrapper.state()).toEqual({index: 20, display: false}); loadingWrapper.setProps({size: 'M' }); expect(loadingWrapper.props().size).toEqual('M'); loadingWrapper.unmount(); }); it ('Loading did not instanse or re-render trigger by didmount setState(), calls components API return no error', () => { Loading.prototype.setShowState(false); Loading.prototype.componentDidMount(); jest.runTimersToTime(100); }); it ('Loading did instanse, calls components API successfully', ()=> { const loadingWrapper = mount(<Loading />); const loadingInst = loadingWrapper.instance(); expect(loadingInst).toBeInstanceOf(Loading); loadingInst.setShowState(false); expect(loadingWrapper.state().display).toEqual(false); loadingWrapper.unmount(); }); });