UNPKG

principles-ui-components

Version:

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

65 lines (51 loc) 2.35 kB
import React, { Component }from 'react'; import {shallow, mount} from 'enzyme'; import ImageItem from '../UI_Component/ImageItem'; jest.useFakeTimers(); const OSD = { layout: {l: 0,t: 0,w: 285,h: 370,}, image: [ { l: 0,t: 0,w: 285,h: 285, url: 'https://u.scdn.co/images/pl/default/e714636cd9f486a6e5e83339893ced444efb6035',}, ], icon: [ { l: 6,t: 8 + 285,w: 66,h: 66, url: 'http://leisure.365jia.cn/uploads/news/folder_1890096/images/61ae2731fecad69152c10561963e27de.jpg',}, ], text: [ { l: 80,t: 8 + 285,w: 195,h: 40,fontSize: 26,fontSizel: 32,fontType: 'SamsungOneGui_600', textAlign: 'left',verticalAlign: 'middle',scrollGap: 60,text: 'Title',}, { l: 80,t: 48 + 285,w: 195,h: 28,fontSize: 20,fontSizel: 24,fontType: 'SamsungOneGui_400', textAlign: 'left',verticalAlign: 'middle',scrollGap: 60,text: 'subTitle subTitle', }, ], progress: {l: 6,t: 275,w: 273,h: 3, rate: -1,}, }; describe ('<ImageItem />', () => { it ('ImageItem unit test, from unfocus to focus', () => { const imageItemWrapper = mount(<ImageItem focus={false} OSD={OSD} TTS={true}/>); expect(imageItemWrapper.props().focus).toEqual(false); imageItemWrapper.setProps({focus: true}); jest.runTimersToTime(500); imageItemWrapper.unmount(); }); it ('ImageItem unit test, from focus to unfocus, then to focus', () => { const imageItemWrapper = mount(<ImageItem focus={true} OSD={OSD} TTS={true}/>); jest.runTimersToTime(500); imageItemWrapper.setProps({focus: false}); imageItemWrapper.setProps({focus: true}); imageItemWrapper.unmount(); }); it ('ImageItem default instanse, calls TTS API successfully', ()=> { const defaultOSd = { layout: {l: 0,t: 0,w: 285,h: 370,}}; const imageItemWrapper = mount(<ImageItem focus={true} OSD={defaultOSd} ttsEnable={true}/>); const imageItemInst = imageItemWrapper.instance(); expect(imageItemInst).toBeInstanceOf(ImageItem); imageItemInst.playTTS(); imageItemWrapper.unmount(); }); it ('ImageItem unit test, test acc', ()=>{ const imageItemWrapper = mount(<ImageItem focus={true} OSD={OSD} highContrast={true} enlarge={true}/>); imageItemWrapper.unmount(); }); });