Skip to main content

SearchProviderControls

How the search contract scripts a provider. A real adapter implements these by mocking its network layer, typically fetch.

This is an interface exported by @mapcairn/core/contracts, checked against version 0.2.0.

Signature​

import type { SearchProviderControls } from "@mapcairn/core/contracts";

interface SearchProviderControls

Methods​

hold​

hold(): void;

Keeps the next request pending until its signal aborts.

respondWithOversizeAnswer​

respondWithOversizeAnswer(): void;

Makes every later request read an answer larger than whatever limit the provider applies to the size of an answer. A provider is free to choose its limit (the subject can lower it so the answer stays small), and the suite requires only that the answer is refused.

willFail​

willFail(kind: SearchErrorKind): void;

Makes every later request fail the way kind describes.

  • kind (SearchErrorKind)

willReturn​

willReturn(results: readonly SearchResult[]): void;

Makes the provider answer every later search with these results, and every later reverse with the first one, or null when the list is empty.

  • results (readonly SearchResult[])

See also​

Source: packages/core/src/contracts/searchProvider.contract.ts:15