UNPKG

principles-ui-components

Version:

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

79 lines (52 loc) 2.75 kB
import React from 'react'; import {shallow, mount} from 'enzyme'; import BasicButton, { STATUS, BUTTON_TYPE } from '../UI_Component/BasicButton'; describe('<BasicButton />', () => { it('BasicButton unit test, Set button focus', () => { const btnWrapper = mount(<BasicButton text={'text button'} buttonType={BUTTON_TYPE.TEXT}/>); expect(btnWrapper.props().text).toEqual('text button'); const btnInst = btnWrapper.instance(); expect(btnInst).toBeInstanceOf(BasicButton); btnInst.SetFocus(true); btnInst.SetFocus(true); btnInst.SetFocus(false); btnInst.DisableButton(true); btnInst.SetFocus(true); btnInst.DisableButton(false); btnInst.DisableButton(false); btnWrapper.unmount(); }); it('BasicButton unit test, Enter button focus', () => { const btnWrapper = mount(<BasicButton text={'text button'} buttonType={BUTTON_TYPE.TEXT}/>); expect(btnWrapper.props().text).toEqual('text button'); btnWrapper.setProps({clickCB: jest.fn()}); const btnInst = btnWrapper.instance(); expect(btnInst).toBeInstanceOf(BasicButton); btnInst.SetFocus(true); btnInst.EnterButton(); const e ={target: 'div', currentTarget: 'div', type: 'animationend', animationName: 'Selected1', preventDefault: jest.fn()}; btnInst.animationDone(e); expect(btnWrapper.props().clickCB).toHaveBeenCalled(); const e2 ={target: 'div', currentTarget: 'div', type: 'animationend', animationName: 'Selected2', preventDefault: jest.fn()}; btnInst.animationDone(e2); btnWrapper.unmount(); }); it('icon basicbutton test, acc test', () => { const iconOSD = {l: 22, t: 23, w: 38, h: 38, url_n: '' }; const btnWrapper = mount(<BasicButton buttonType={BUTTON_TYPE.ICON} iconOSD={iconOSD}/>); const btnInst = btnWrapper.instance(); expect(btnInst).toBeInstanceOf(BasicButton); btnInst.SetFocus(true); const iconOSD2 = {l: 22, t: 23, w: 38, h: 38, url_n: '', url_f: '',}; btnWrapper.setProps({iconOSD: iconOSD2, highContrast: true, ttsEnable: true}); btnWrapper.setProps({ttsEnable: true}); btnInst.playTTS(); btnWrapper.unmount(); }); it('Text basicbutton test, custom buttonScale, and enlarge ', () => { const btnWrapper = mount(<BasicButton text={'text button'} buttonType={BUTTON_TYPE.TEXT} />); const buttonScale = 1.2; btnWrapper.setProps({ buttonScale: buttonScale, enlarge: true }); btnWrapper.unmount(); }); });