Repository navigation
Commit 6895d32
committed
test(core): assert the pretext attachment by running the runtime
Review correctly pointed out that nothing here fails if the attachment is
removed again. pretext.test.ts asserts the shape of the module export, which
passes whether or not entry.ts ever attaches it, and a snippet check over the
bundle would be decorative: fitTextFontSize.ts imports prepare/layout from
@chenglou/pretext directly, so the name is already in the output through an
unrelated path.
Evaluate the built runtime in a jsdom window and read window.__hyperframes back
instead. That is the assertion that actually breaks. Verified by deleting the
attachment line: the check exits 1 with "window.__hyperframes.pretext is not
attached", and passes again once restored.
Covers fitTextFontSize and getVariables the same way, and asserts clearCache
and setLocale stay off the surface so the determinism choice is enforced rather
than just documented.
requestAnimationFrame is stubbed rather than enabling jsdom's pretendToBeVisual,
which starts a frame loop that keeps the process alive.
Also answers the open question raised in review about the withheld clearCache.
The upstream cache is keyed by (segment, font), with segments coming from
Intl.Segmenter at word granularity, so it grows with the number of distinct
words a composition renders, not with frames. A per-frame counter or typewriter
reuses existing entries; only new words allocate. Recorded next to the omission.1 parent 58c20ae commit 6895d32
2 files changed
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
30 | 90 | | |
31 | 91 | | |
32 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
0 commit comments