UNPKG

principles-ui-components

Version:

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

46 lines (34 loc) 1.64 kB
import React, { Component }from 'react'; import {shallow, mount} from 'enzyme'; import ScrollBar from '../UI_Component/ScrollBar'; jest.useFakeTimers(); describe ('<ScrollBar />', () => { it ('ScrollBar unit test, vertical type', () => { const barWrapper = mount(<ScrollBar barType={'v'} bgWidth={3} bgHeight={100} barPercent={0.1} scrollPercent={0.1}/>); expect(barWrapper.state().allOpacity).toBe(1); jest.runTimersToTime(1000); expect(barWrapper.state().allOpacity).toBe(0); barWrapper.setProps({scrollPercent: 1.1}); jest.runTimersToTime(1000); barWrapper.unmount(); }); it ('ScrollBar unit test, horizontal type ', () => { const barWrapper = mount(<ScrollBar barType={'h'} bgWidth={100} bgHeight={3} barPercent={0.1} scrollPercent={0.1}/>); expect(barWrapper.state().allOpacity).toBe(1); jest.runTimersToTime(1000); expect(barWrapper.state().allOpacity).toBe(0); barWrapper.setProps({scrollPercent: 1.1}); jest.runTimersToTime(1000); barWrapper.unmount(); }); it ('ScrollBar unit test, test acc', () => { const barWrapper = mount(<ScrollBar barType={'h'} bgWidth={100} bgHeight={3} barPercent={0.1} scrollPercent={0.1} highContarstValue={true}/>); expect(barWrapper.props().highContarstValue).toEqual(true); barWrapper.unmount(); }); it ('ScrollBar unit test, error type acc', () => { const barWrapper = mount(<ScrollBar barType={'error'} bgWidth={100} bgHeight={3} barPercent={0.1} scrollPercent={0.1}/>); barWrapper.setProps({ barType:'error' }); barWrapper.unmount(); }); });