I been testing this component but it outputs CustomEvent is not defined: My Code below
emitEvent(detail) {
Utils.setCustomEvent();
const event = new CustomEvent(detail.eventName, {
detail,
bubbles: true,
cancelable: false,
});
document.dispatchEvent(event);
}
Enzyume Test code: How can I test the new CustomEvent dunction which is in EmitEvent()
describe('<ScheduleComp />', () => {
describe('render ', () => {
const detail = {
key: 'productOffering',
state: 'update',
eventName: 'data',
cardName: 'data',
}
const wrapper = shallow(<ScheduleComp {...ScheduleCompData} />);
assert.isNotNull(wrapper);
it('Should verify if', () => {
const emitEvent = spy();
const CustomEvent = spy();
const component = new ScheduleComp({ ...ScheduleCompData,
emitEvent,
CustomEvent
});
component.flipCard(event);
component.emitEvent(detail);
component.CustomEvent(detail.eventName);
});
});
});
Aucun commentaire:
Enregistrer un commentaire