MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / installVTMock

Function installVTMock

test/commands/viewTransition.js:8–29  ·  view source on GitHub ↗

* Install a minimal document.startViewTransition mock. `window.__vtLog` records * lifecycle events (start, skipped, finished) so tests can assert escape-path * behavior on the view transition itself rather than the surrounding DOM.

(evaluate)

Source from the content-addressed store, hash-verified

6 * behavior on the view transition itself rather than the surrounding DOM.
7 */
8async function installVTMock(evaluate) {
9 await evaluate(() => {
10 window.__vtLog = []
11 document.startViewTransition = function (arg) {
12 window.__vtLog.push('start')
13 var skipped = false
14 var updateFn = typeof arg === 'function' ? arg : arg.update
15 var updateP
16 try { updateP = updateFn() } catch (e) { updateP = Promise.reject(e) }
17 var finished = Promise.resolve(updateP).then(
18 function () { window.__vtLog.push('finished'); },
19 function () { window.__vtLog.push('finished-err'); }
20 )
21 return {
22 finished: finished,
23 updateCallbackDone: Promise.resolve(updateP),
24 ready: Promise.resolve(),
25 skipTransition: function () { skipped = true; window.__vtLog.push('skipped') },
26 }
27 }
28 })
29}
30
31test.describe("the start view transition command", () => {
32

Callers 1

viewTransition.jsFile · 0.85

Calls 2

evaluateFunction · 0.50
resolveMethod · 0.45

Tested by

no test coverage detected