OpenMediaCenter/src/elements/Popups/PopupBase.test.js

27 lines
660 B
JavaScript
Raw Normal View History

2020-12-29 19:39:30 +00:00
import {shallow} from 'enzyme';
import React from 'react';
import PopupBase from './PopupBase';
describe('<PopupBase/>', function () {
it('renders without crashing ', function () {
const wrapper = shallow(<PopupBase/>);
wrapper.unmount();
});
it('simulate keypress', function () {
let events = [];
document.addEventListener = jest.fn((event, cb) => {
events[event] = cb;
});
const func = jest.fn();
shallow(<PopupBase onHide={() => func()}/>);
// trigger the keypress event
events.keyup({key: 'Escape'});
expect(func).toBeCalledTimes(1);
});
});