mirror of
https://github.com/penpot/penpot.git
synced 2025-05-13 01:56:39 +02:00
✨ Import text-editor code into the repository
This commit is contained in:
parent
68397edd4d
commit
04a0d867b0
65 changed files with 11112 additions and 7 deletions
29
frontend/text-editor/editor/Event.test.js
Normal file
29
frontend/text-editor/editor/Event.test.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { describe, test, expect, vi } from 'vitest';
|
||||
import { addEventListeners, removeEventListeners } from './Event';
|
||||
|
||||
/* @vitest-environment jsdom */
|
||||
describe('Event', () => {
|
||||
test('addEventListeners should add event listeners to an element using an object', () => {
|
||||
const clickSpy = vi.fn();
|
||||
const events = {
|
||||
click: clickSpy
|
||||
}
|
||||
const element = document.createElement('div');
|
||||
addEventListeners(element, events);
|
||||
element.dispatchEvent(new Event('click'));
|
||||
expect(clickSpy).toBeCalled();
|
||||
});
|
||||
|
||||
test('removeEventListeners should remove event listeners to an element using an object', () => {
|
||||
const clickSpy = vi.fn();
|
||||
const events = {
|
||||
click: clickSpy,
|
||||
};
|
||||
const element = document.createElement("div");
|
||||
addEventListeners(element, events);
|
||||
element.dispatchEvent(new Event("click"));
|
||||
removeEventListeners(element, events);
|
||||
element.dispatchEvent(new Event('click'))
|
||||
expect(clickSpy).toBeCalledTimes(1);
|
||||
})
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue