All files / src/stories frame.canvas.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 3/3
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                  5x 5x   5x    
import {within} from "@storybook/test";
/*
    example of use
 
import {frameCanvas} from "./frame.canvas";
 
export const ModuleByName:Story  =
{   args : {title: '4. module path by symbolic name', body:`
    <iframe src="../demo/module-url-sb-4.html" name="sb" data-testid="fr"></iframe>
 
`}
,   play: async ({canvasElement}) =>
    {
        const canvas = within(canvasElement);
        await canvas.findByText(ModuleByName.args!.title as string);
        const frCanvas = await frameCanvas('fr',canvas);
 
        await expect(await frCanvas.findByText('👌 from embed-relative-hash invoking')).toBeInTheDocument();
    },
};
 */
    export async function
frameCanvas(frameTestId: string, canvas: ReturnType<typeof within>)
    : Promise<ReturnType<typeof within>>
{
    const frEl: HTMLIFrameElement = await canvas.findByTestId(frameTestId);
    return new Promise(resolve => frEl.addEventListener('load', () =>
    {
        resolve(within(frEl.contentWindow?.document.documentElement!));
    }));
}