Utilização

Fake one native module.

tsx
// 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

ts
export type ModuleFake = Readonly<Record<string, unknown>>;

Tipo

ts
{    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.