UNPKG

riot-test-utils

Version:
52 lines (51 loc) 1.81 kB
import * as riot from 'riot'; import Renderer, { RiotElement } from './Renderer'; import MountOptions from './MountOptions'; export interface MountFunction { (this: typeof riot, element: Element, tagName: string, opts: any): riot.TagInstance[]; } /** * base class of some shallow renderer for `riot` */ export default class RiotRendererBase implements Renderer { private mount; private context; private instance; private rendered; constructor(mount: MountFunction); loadTags(source: string): string[]; unloadTag(tagName: string): void; /** * Execute mount and rendering * * @param src multiple tag sources * @param name name of the tag to render * @param opts tag interface * @param options options to mount * @returns mounted element */ render(src: string, name: string, opts?: riot.TagOpts, options?: MountOptions): RiotElement; /** * Execute shallow rendering * * @param src single tag source or tag name preloaded to render * @param opts tag interface * @returns rendered tree */ render(src: string, opts?: riot.TagOpts, options?: MountOptions): RiotElement; /** * instanciate tag * * @param name tag name * @param opts tag interface * @param children children to yield. Ignored currently * @param options options to mount * @returns created instance unmounted */ createInstance(name: string, opts?: riot.TagOpts, children?: ReadonlyArray<RiotElement>, options?: MountOptions): riot.TagInstance; /** Get created instance of `render` */ getMountedInstance(): riot.TagInstance; /** Get latest result of `render` */ getRenderedOutput(): RiotElement; unmount(): void; }