mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-27 23:27:09 +09:00
## Description 1. improved composeEventHandlers implementation 2. delete value text, then hit backspace - same as reset 3. in advanced panel all property tooltips now show "Delete property" wording instead of "Reset value" <img width="363" alt="image" src="https://github.com/user-attachments/assets/f4ad7ec4-892c-4774-9143-ac2b26c55cde" /> ## Steps for reproduction 1. click button 4. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { describe, test, expect, vi } from "vitest";
|
|
import { composeEventHandlers } from "./event-utils";
|
|
|
|
describe("composeEventHandlers", () => {
|
|
test("executes handlers in sequence", () => {
|
|
const handler1 = vi.fn();
|
|
const handler2 = vi.fn();
|
|
const event = {};
|
|
|
|
const composed = composeEventHandlers([handler1, handler2]);
|
|
composed(event);
|
|
|
|
expect(handler1).toHaveBeenCalledWith(event);
|
|
expect(handler2).toHaveBeenCalledWith(event);
|
|
});
|
|
|
|
test("stops execution if event.defaultPrevented is true", () => {
|
|
const handler1 = vi.fn((event) => {
|
|
event.defaultPrevented = true;
|
|
});
|
|
const handler2 = vi.fn();
|
|
const event = {};
|
|
|
|
const composed = composeEventHandlers([handler1, handler2]);
|
|
composed(event);
|
|
|
|
expect(handler1).toHaveBeenCalled();
|
|
expect(handler2).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test("continues execution when checkForDefaultPrevented is false", () => {
|
|
const handler1 = vi.fn((event) => {
|
|
event.defaultPrevented = true;
|
|
});
|
|
const handler2 = vi.fn();
|
|
const event = {};
|
|
|
|
const composed = composeEventHandlers([handler1, handler2], {
|
|
checkForDefaultPrevented: false,
|
|
});
|
|
composed(event);
|
|
|
|
expect(handler1).toHaveBeenCalled();
|
|
expect(handler2).toHaveBeenCalled();
|
|
});
|
|
});
|