@moltenship/calendar-testing 0.0.0-stage → 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +68 -2
- package/dist/index.d.mts +664 -0
- package/dist/index.mjs +1643 -0
- package/package.json +52 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Timofey Maximov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @moltenship/calendar-testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Test helpers for apps built on Moltenship Time: test the calendar you built, with your copies of
|
|
4
|
+
the registry views, your policies and your save logic.
|
|
5
|
+
|
|
6
|
+
- **A deterministic environment.** `createTestEnvironment()` fixes `now`, the time zone, the locale,
|
|
7
|
+
the week rules and the direction, and passes them to `Root` as props. The calendar reads the
|
|
8
|
+
current time only from `now` or `clock`, so nothing global is patched.
|
|
9
|
+
- **Builders and fixtures.** `buildEvent`, `buildAllDayEvent`, `buildResource`,
|
|
10
|
+
`buildRecurringEvent` and `buildAvailability` make typed records with defaults you override.
|
|
11
|
+
`denseDayFixture`, `dstWeekFixture`, `multiZoneSeriesFixture` and `resourceDayFixture` are ready
|
|
12
|
+
datasets for contract tests.
|
|
13
|
+
- **A render harness.** `renderCalendar(Calendar, options)` renders your calendar's `Root` with
|
|
14
|
+
controlled events inside React's `act`, applies the changes it saves, and records every
|
|
15
|
+
`onEventChange` and `onEventChangeResult` call. `hydrateCalendar` renders on the server first and
|
|
16
|
+
fails on a hydration mismatch.
|
|
17
|
+
- **Queries and drivers.** Find events by title, ID or start, and day cells, time columns and
|
|
18
|
+
resources by the attributes views carry for the pointer layer. `calendar.keyboard` grabs, steps,
|
|
19
|
+
resizes, creates, drops and cancels through the keyboard grab mode; `calendar.pointer` drags with
|
|
20
|
+
a mouse, a pen or a finger where the page is laid out.
|
|
21
|
+
- **Assertions.** `settled()` waits for pending changes; `announcements()` and `lastAnnouncement()`
|
|
22
|
+
read the `Announcer`; `placementOf(event)` says where an event shows, as comparable text.
|
|
23
|
+
|
|
24
|
+
It uses only the public API of `@moltenship/calendar` and `@moltenship/calendar-recurrence`, and
|
|
25
|
+
depends on no test runner: it works in Vitest with jsdom or happy-dom, and in Vitest's browser
|
|
26
|
+
mode, which the pointer drivers need: jsdom and happy-dom don't lay pages out.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { buildEvent, cleanup, renderCalendar } from "@moltenship/calendar-testing";
|
|
30
|
+
import { afterEach, expect, test } from "vitest";
|
|
31
|
+
|
|
32
|
+
import { Calendar } from "./calendar";
|
|
33
|
+
|
|
34
|
+
afterEach(cleanup);
|
|
35
|
+
|
|
36
|
+
test("a saved move reaches onEventChange", async () => {
|
|
37
|
+
const calendar = await renderCalendar(Calendar, {
|
|
38
|
+
events: [buildEvent({ title: "Standup", start: "2026-10-08T09:00" })],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Focus the event, Space, four slots down, Enter.
|
|
42
|
+
await calendar.keyboard.moveEvent("Standup", { down: 4 });
|
|
43
|
+
await calendar.settled();
|
|
44
|
+
|
|
45
|
+
expect(calendar.changes.map((change) => change.cause)).toEqual(["move"]);
|
|
46
|
+
expect(calendar.placementOf("Standup").range).toBe("2026-10-08T10:00:00Z/2026-10-08T11:00:00Z");
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add -D @moltenship/calendar-testing
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- React 19 and React DOM 19, peer dependencies.
|
|
57
|
+
- A runtime with `Temporal` (Node.js 26 and later include it). Elsewhere, add
|
|
58
|
+
`if (!("Temporal" in globalThis)) await import("temporal-polyfill/global");` to your test setup
|
|
59
|
+
file; the package never installs a polyfill itself.
|
|
60
|
+
- TypeScript 6 or later with `"lib": ["DOM", "DOM.Iterable", "ESNext"]`.
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
- [Testing](https://time.molten.sh/docs/testing)
|
|
65
|
+
- [Repository](https://github.com/Moltenship/time)
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|