Usage

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'));
});

Type declaration

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

Type

ts
{    readonly [x: string]: unknown;}
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.