@remit/ui 0.0.127 → 0.0.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/components/brief-sections.keyboard.test.ts +8 -36
- package/src/components/calendar-types.ts +2 -0
- package/src/components/compose-body.language.test.ts +8 -58
- package/src/components/compose-body.spellcheck.test.ts +8 -55
- package/src/components/event-editor.render.test.ts +2 -2
- package/src/components/event-suggestion-card.render.test.ts +1 -0
- package/src/components/event-suggestion-card.stories.tsx +1 -0
- package/src/components/filter-rule-editor.create.test.ts +10 -59
- package/src/components/folder-tree-picker.create.test.ts +18 -63
- package/src/components/message-list-pane.brief-filter.test.ts +4 -31
- package/src/components/nav-link-surface.interaction.test.ts +7 -34
- package/src/components/nav-sidebar.keyboard.test.ts +11 -40
- package/src/components/password-input.render.test.ts +8 -50
- package/src/components/plain-text-editor.mount.test.ts +11 -66
- package/src/components/rich-text-editor.mount.test.ts +9 -63
- package/src/components/rich-text-formatting.test.ts +27 -45
- package/src/components/rich-text-image-node.test.ts +60 -83
- package/src/components/rich-text-markdown.test.ts +3 -25
- package/src/components/rich-text-paste.test.ts +28 -42
- package/src/components/rich-text-spellcheck-menu.test.ts +28 -94
- package/src/components/rich-text-spellcheck.test.ts +11 -65
- package/src/components/swipeable-row.gesture.test.ts +8 -42
- package/src/components/touch-list.follows-sections.test.ts +4 -27
- package/src/lib/adopted-html.test.ts +3 -22
- package/src/lib/compose-language.test.ts +2 -7
- package/src/lib/roving-focus.test.ts +16 -43
- package/src/lib/use-list-cursor.test.ts +3 -27
- package/src/lib/use-list-keyboard.test.ts +6 -30
- package/src/lib/use-long-press.test.ts +12 -43
- package/src/lib/use-rendered-row-ids.test.ts +3 -24
- package/src/lib/use-selection.hook.test.ts +3 -26
- package/src/lib/use-suggest-list.test.ts +5 -29
- package/src/lib/use-triage-keyboard.test.ts +6 -29
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
* a second shift-range extends from.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import "@remit/test-dom";
|
|
8
9
|
import assert from "node:assert/strict";
|
|
9
|
-
import {
|
|
10
|
-
import type { JSDOM } from "jsdom";
|
|
10
|
+
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
11
11
|
import { act, createElement } from "react";
|
|
12
12
|
import { createRoot, type Root } from "react-dom/client";
|
|
13
13
|
import { useSelection } from "./use-selection.js";
|
|
14
14
|
|
|
15
|
-
let dom: JSDOM;
|
|
16
15
|
let container: HTMLElement;
|
|
17
16
|
let root: Root;
|
|
18
17
|
let api: ReturnType<typeof useSelection>;
|
|
@@ -34,30 +33,8 @@ const run = (fn: () => void) => {
|
|
|
34
33
|
|
|
35
34
|
const selected = () => Array.from(api.selectedIds);
|
|
36
35
|
|
|
37
|
-
before(async () => {
|
|
38
|
-
const { JSDOM: JSDOMCtor } = await import("jsdom");
|
|
39
|
-
dom = new JSDOMCtor(
|
|
40
|
-
"<!doctype html><html><body><div id=root></div></body></html>",
|
|
41
|
-
{ url: "http://localhost/", pretendToBeVisual: true },
|
|
42
|
-
);
|
|
43
|
-
globalThis.window = dom.window as unknown as typeof globalThis.window;
|
|
44
|
-
globalThis.document = dom.window.document;
|
|
45
|
-
globalThis.HTMLElement = dom.window.HTMLElement;
|
|
46
|
-
globalThis.Element = dom.window.Element;
|
|
47
|
-
globalThis.SVGElement = dom.window.SVGElement;
|
|
48
|
-
(
|
|
49
|
-
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
50
|
-
).IS_REACT_ACT_ENVIRONMENT = true;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
after(() => {
|
|
54
|
-
dom.window.close();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
36
|
beforeEach(() => {
|
|
58
|
-
container =
|
|
59
|
-
"root",
|
|
60
|
-
) as unknown as HTMLElement;
|
|
37
|
+
container = document.getElementById("root") as unknown as HTMLElement;
|
|
61
38
|
container.innerHTML = "";
|
|
62
39
|
root = createRoot(container);
|
|
63
40
|
mount();
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
* themselves are pure and tested in `suggest-keys.test.ts`.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import "@remit/test-dom";
|
|
9
10
|
import assert from "node:assert/strict";
|
|
10
|
-
import {
|
|
11
|
-
import type { JSDOM } from "jsdom";
|
|
11
|
+
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
12
12
|
import { act, createElement, useState } from "react";
|
|
13
13
|
import { createRoot, type Root } from "react-dom/client";
|
|
14
14
|
import { useSuggestList } from "./use-suggest-list.js";
|
|
15
15
|
|
|
16
|
-
let dom: JSDOM;
|
|
17
16
|
let container: HTMLElement;
|
|
18
17
|
let root: Root;
|
|
19
18
|
|
|
@@ -43,7 +42,7 @@ function mount(options: string[]) {
|
|
|
43
42
|
act(() => {
|
|
44
43
|
root.render(createElement(Field, { options }));
|
|
45
44
|
});
|
|
46
|
-
const field =
|
|
45
|
+
const field = document.getElementById("field");
|
|
47
46
|
assert.ok(field, "field did not mount");
|
|
48
47
|
// React's change-event polyfill tracks the focused input across keystrokes;
|
|
49
48
|
// keys arriving at an unfocused field are not a state this ever sees.
|
|
@@ -54,7 +53,7 @@ function mount(options: string[]) {
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
function press(field: Element, key: string) {
|
|
57
|
-
const event = new
|
|
56
|
+
const event = new KeyboardEvent("keydown", {
|
|
58
57
|
key,
|
|
59
58
|
bubbles: true,
|
|
60
59
|
cancelable: true,
|
|
@@ -65,32 +64,9 @@ function press(field: Element, key: string) {
|
|
|
65
64
|
return event;
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
before(async () => {
|
|
69
|
-
const { JSDOM: JSDOMCtor } = await import("jsdom");
|
|
70
|
-
dom = new JSDOMCtor(
|
|
71
|
-
"<!doctype html><html><body><div id=root></div></body></html>",
|
|
72
|
-
{ url: "http://localhost/", pretendToBeVisual: true },
|
|
73
|
-
);
|
|
74
|
-
globalThis.window = dom.window as unknown as typeof globalThis.window;
|
|
75
|
-
globalThis.document = dom.window.document;
|
|
76
|
-
globalThis.HTMLElement = dom.window.HTMLElement;
|
|
77
|
-
globalThis.Element = dom.window.Element;
|
|
78
|
-
globalThis.SVGElement = dom.window.SVGElement;
|
|
79
|
-
globalThis.KeyboardEvent = dom.window.KeyboardEvent;
|
|
80
|
-
(
|
|
81
|
-
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
82
|
-
).IS_REACT_ACT_ENVIRONMENT = true;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
after(() => {
|
|
86
|
-
dom.window.close();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
67
|
beforeEach(() => {
|
|
90
68
|
accepted.length = 0;
|
|
91
|
-
container =
|
|
92
|
-
"root",
|
|
93
|
-
) as unknown as HTMLElement;
|
|
69
|
+
container = document.getElementById("root") as unknown as HTMLElement;
|
|
94
70
|
container.innerHTML = "";
|
|
95
71
|
root = createRoot(container);
|
|
96
72
|
});
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
* a real keydown reaches, what the `g …` window does across two presses, and
|
|
5
5
|
* what the layer leaves bound after it is taken down.
|
|
6
6
|
*/
|
|
7
|
+
import "@remit/test-dom";
|
|
7
8
|
import assert from "node:assert/strict";
|
|
8
|
-
import {
|
|
9
|
-
import type { JSDOM } from "jsdom";
|
|
9
|
+
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
10
10
|
import { act, createElement } from "react";
|
|
11
11
|
import { createRoot, type Root } from "react-dom/client";
|
|
12
12
|
import type { TriageAction, TriageHandlers } from "./keymap.js";
|
|
13
13
|
import { useTriageKeyboard } from "./use-triage-keyboard.js";
|
|
14
14
|
|
|
15
|
-
let dom: JSDOM;
|
|
16
15
|
let container: HTMLElement;
|
|
17
16
|
let root: Root;
|
|
18
17
|
let fired: TriageAction[];
|
|
@@ -39,9 +38,9 @@ const mount = (enabled = true) => {
|
|
|
39
38
|
const press = (
|
|
40
39
|
key: string,
|
|
41
40
|
init: KeyboardEventInit = {},
|
|
42
|
-
target: EventTarget =
|
|
41
|
+
target: EventTarget = document.body,
|
|
43
42
|
): KeyboardEvent => {
|
|
44
|
-
const event = new
|
|
43
|
+
const event = new KeyboardEvent("keydown", {
|
|
45
44
|
key,
|
|
46
45
|
bubbles: true,
|
|
47
46
|
cancelable: true,
|
|
@@ -53,31 +52,9 @@ const press = (
|
|
|
53
52
|
return event as unknown as KeyboardEvent;
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
before(async () => {
|
|
57
|
-
const { JSDOM: JSDOMCtor } = await import("jsdom");
|
|
58
|
-
dom = new JSDOMCtor(
|
|
59
|
-
"<!doctype html><html><body><div id=root></div></body></html>",
|
|
60
|
-
{ url: "http://localhost/", pretendToBeVisual: true },
|
|
61
|
-
);
|
|
62
|
-
globalThis.window = dom.window as unknown as typeof globalThis.window;
|
|
63
|
-
globalThis.document = dom.window.document;
|
|
64
|
-
globalThis.HTMLElement = dom.window.HTMLElement;
|
|
65
|
-
globalThis.Element = dom.window.Element;
|
|
66
|
-
globalThis.SVGElement = dom.window.SVGElement;
|
|
67
|
-
(
|
|
68
|
-
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
69
|
-
).IS_REACT_ACT_ENVIRONMENT = true;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
after(() => {
|
|
73
|
-
dom.window.close();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
55
|
beforeEach(() => {
|
|
77
56
|
fired = [];
|
|
78
|
-
container =
|
|
79
|
-
"root",
|
|
80
|
-
) as unknown as HTMLElement;
|
|
57
|
+
container = document.getElementById("root") as unknown as HTMLElement;
|
|
81
58
|
container.innerHTML = "";
|
|
82
59
|
root = createRoot(container);
|
|
83
60
|
});
|
|
@@ -123,7 +100,7 @@ describe("useTriageKeyboard", () => {
|
|
|
123
100
|
|
|
124
101
|
it("stays inert while focus is in an editable surface", () => {
|
|
125
102
|
mount();
|
|
126
|
-
const field =
|
|
103
|
+
const field = document.getElementById("field");
|
|
127
104
|
assert.ok(field);
|
|
128
105
|
press("j", {}, field);
|
|
129
106
|
assert.deepEqual(fired, []);
|