tests.Mutation
One view mutation, as native/shared/Mutation.h has it; views by number, 0 the root.
Verwendung
Inspect committed view mutations.
// Inspect committed view mutations.
import { Button, Show, Text, VStack, signal } from 'kuito';
import { assert, press, render, screen, test, type Mutation } from 'kuito/tests';
function Alarm() {
const armed = signal(false);
return (
<VStack>
<Show when={armed.value}>
<Text>Armed</Text>
</Show>
<Button onPress={() => (armed.value = true)}>Arm</Button>
</VStack>
);
}
const created = (mutations: readonly Mutation[]) =>
mutations.filter((mutation) => mutation.op === 'create').map((mutation) => mutation.kind);
test('arming adds one label, and nothing else', async () => {
const app = await render(<Alarm />);
const before = app.mutations.length;
await press(screen.getByText('Arm'));
assert.deepEqual(created(app.mutations.slice(before)), ['Text']);
});Typdeklaration
export type Mutation =
| { op: 'create'; id: number; parent: number; kind: string; label: string; flattened: boolean }
| { op: 'remove'; id: number }
| { op: 'move'; id: number; parent: number; index: number }
| { op: 'flatten'; id: number; flattened: boolean }
| ({ op: 'prop'; id: number; name: string } & PropValue)
| { op: 'command'; id: number; name: string; argument: string }
/** The UI-thread operations, as plain data. */
| { op: 'ui'; operations: unknown[] }
| { op: 'uiScript'; source: string; url: string }
/** Load the UI kernel the host ships, if it is the one `hash` names. */
| { op: 'uiKernel'; hash: string }
/** Load the app's UI bundle the host ships, if it is the one `hash` names. */
| { op: 'uiBundle'; hash: string; url: string };Mitglieder 1
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
op | "create" | "remove" | "move" | "flatten" | "prop" | "command" | "ui" | "uiScript" | "uiKernel" | "uiBundle" | Ja | — |
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.