principles-ui-components
Version:
Supporting UI controller for Tizen TV web application, which developed base on React Framework.
21 lines (15 loc) • 842 B
JavaScript
import CommonAPI from '../UI_Component/common/CommonAPI';
//import {JSDOM} from 'jsdom';
//const { document } = (new JSDOM(`...`)).window;
describe('<CommonAPI />', () => {
it('CommonAPI unit test, get right width', () => {
const measure = jest.fn((data)=> { return ({width : 0}); });
const getContext = jest.fn((type)=>{ return ({font:'', measureText: measure}); });
const createElement = jest.fn((ty) => { return ({getContext: getContext}); } );
document.createElement = createElement;
let width = CommonAPI.getTextWidth('message',26,'SamsungOneGui_600');
const createElement2 = jest.fn((ty) => { return ({getContext: jest.fn(() => {return null;})}); } );
document.createElement = createElement2;
width = CommonAPI.getTextWidth('message',26,'SamsungOneGui_600');
});
});