tests.PropValue
A prop's value, typed by its manifest kind as native/shared/Mutation.h's Value.
Utilização
Inspect a native property value.
// Inspect a native property value.
import { Button, Show, Text, VStack, signal } from 'kuito';
import { assert, press, render, screen, test, type PropValue } from 'kuito/tests';
function Alarm() {
const armed = signal(false);
return (
<VStack>
<Show when={armed.value}>
<Text color="#ff3b30">Armed</Text>
</Show>
<Button onPress={() => (armed.value = true)}>Arm</Button>
</VStack>
);
}
// A color crosses as a 0xRRGGBBAA number.
const red: PropValue = { type: 'color', value: 0xff3b30ff };
test('arming shows a red warning', async () => {
const app = await render(<Alarm />);
const before = app.mutations.length;
await press(screen.getByText('Arm'));
const color = app.mutations
.slice(before)
.find((mutation) => mutation.op === 'prop' && mutation.name === 'color');
assert.equal(color?.op === 'prop' && color.value, red.value);
});Declaração do tipo
export type PropValue =
| { type: 'null'; value: null }
| { type: 'number'; value: number | null }
| { type: 'boolean'; value: boolean }
| { type: 'text' | 'json'; value: string }
/** Its index among the prop's manifest values, and the value as written. */
| { type: 'enum'; value: string; index: number }
/** 0xRRGGBBAA. */
| { type: 'color'; value: number }
| { type: 'keys'; value: KeyEdit[] }
/** A structured prop's value as the kernel wrote it, checked against its schema. */
| { type: 'struct'; value: unknown };Membros 2
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | "number" | "boolean" | "color" | "text" | "keys" | "null" | "json" | "enum" | "struct" | Sim | — |
value | unknown | Sim | — |
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.