Verwendung

Assert calls to a native capability.

tsx
// Assert calls to a native capability.
import { Button, haptics } from 'kuito';
import { assert, press, render, screen, test, type ModuleCall } from 'kuito/tests';

const Confirm = () => <Button onPress={() => void haptics.notification('success')}>Confirm</Button>;

const named = (calls: readonly ModuleCall[], module: string) =>
  calls.filter((call) => call.module === module);

test('confirming plays a success haptic', async () => {
  const app = await render(<Confirm />, { modules: { Haptics: { notification: () => {} } } });

  await press(screen.getByText('Confirm'));

  assert.deepEqual(
    named(app.calls, 'Haptics').map((call) => [call.name, call.args]),
    [['notification', ['success']]],
  );
});

Typdeklaration

ts
export interface ModuleCall {
  module: string;
  name: string;
  args: unknown[];
}

Mitglieder 3

NameTypErforderlichBeschreibung
modulestringJa—
namestringJa—
argsunknown[]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.