tests.ModuleFake
A module's fakes by member name: a function for a function, the value for a live value.
Utilização
Fake one native module.
// Fake one native module.
import { Button, Text, VStack, clipboard, signal } from 'kuito';
import { assert, press, render, screen, test, type ModuleFake } from 'kuito/tests';
function Paste() {
const pasted = signal('');
return (
<VStack>
<Button onPress={async () => (pasted.value = await clipboard.readText())}>Paste</Button>
<Text>{pasted.value}</Text>
</VStack>
);
}
// The Clipboard module's members, by name: what each call returns.
const clipboardWith = (text: string): ModuleFake => ({
hasText: async () => text !== '',
readText: async () => text,
});
test('paste shows what the clipboard holds', async () => {
await render(<Paste />, { modules: { Clipboard: clipboardWith('KUITO-42') } });
await press(screen.getByText('Paste'));
assert.ok(screen.getByText('KUITO-42'));
});Declaração do tipo
export type ModuleFake = Readonly<Record<string, unknown>>;Tipo
{ readonly [x: string]: unknown;}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.