Socket
Socket
Sign inDemoInstall

@desk-framework/frame-test

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@desk-framework/frame-test - npm Package Compare versions

Comparing version 4.0.0-dev.13 to 4.0.0-dev.14

23

.test-run/tests/app.js

@@ -73,3 +73,26 @@ import { app, bound, Activity, UIButton, UICell, UILabel, UITextField, ViewComposite, } from "@desk-framework/frame-core";

});
test("Alert dialog can be dismissed", async (t) => {
let p = app.showAlertDialogAsync("Foo");
let dialog = await t.expectMessageDialogAsync(100, "Foo");
await dialog.confirmAsync();
let result = await p;
expect(result).toBeUndefined();
});
test("Confirm dialog can be cancelled", async (t) => {
let p = app.showConfirmDialogAsync("Foo?");
await (await t.expectMessageDialogAsync(100, /^Foo/)).cancelAsync();
let result = await p;
expect(result).toBeFalsy();
});
test("Confirm dialog can be confirmed", async (t) => {
let p = app.showConfirmDialogAsync((d) => {
d.messages = ["Foo?", "Bar?"];
d.confirmLabel = "Yes";
});
let dialog = await t.expectMessageDialogAsync(10, /Foo/, /Bar/);
await dialog.clickAsync("Yes");
let result = await p;
expect(result).toBeTruthy();
});
});
//# sourceMappingURL=app.js.map

@@ -5,2 +5,11 @@ import { Observer, RenderContext, View } from "@desk-framework/frame-core";

import { TestOutputElement } from "../app/TestOutputElement.js";
export declare class RenderedTestMessageDialog {
constructor(dialogOutput: OutputAssertion);
labels: TestOutputElement[];
buttons: TestOutputElement[];
clickAsync(button: string): Promise<void>;
confirmAsync(): Promise<void>;
cancelAsync(): Promise<void>;
private _click;
}
/**

@@ -79,2 +88,3 @@ * A class that represents an in-memory application render context

expectOutputAsync(timeout: number, ...select: OutputSelectFilter[]): Promise<OutputAssertion>;
expectMessageDialogAsync(timeout: number, ...match: Array<string | RegExp>): Promise<RenderedTestMessageDialog>;
/** Returns an object representation of (selected) output */

@@ -81,0 +91,0 @@ getOutputDump(...select: OutputSelectFilter[]): any[];

@@ -9,2 +9,30 @@ import { RenderContext, app, } from "@desk-framework/frame-core";

const MAX_SCHED_RUNTIME = 30;
export class RenderedTestMessageDialog {
constructor(dialogOutput) {
this.labels.push(...dialogOutput.containing({ type: "label" }).elements);
this.buttons.push(...dialogOutput.containing({ type: "button" }).elements);
}
labels = [];
buttons = [];
async clickAsync(button) {
for (let b of this.buttons) {
if (b.text === button)
return this._click(b);
}
this._click();
}
async confirmAsync() {
return this._click(this.buttons[0]);
}
async cancelAsync() {
let button = this.buttons[this.buttons.length - 1];
return this._click(button);
}
async _click(button) {
if (!button)
throw Error("Message dialog button not found");
button?.click();
return Promise.resolve().then(() => Promise.resolve());
}
}
/**

@@ -166,2 +194,12 @@ * A class that represents an in-memory application render context

}
async expectMessageDialogAsync(timeout, ...match) {
let dialogOut = await this.expectOutputAsync(timeout, {
accessibleRole: "alertdialog",
});
dialogOut.getSingle();
for (let m of match) {
dialogOut.containing({ type: "label", text: m }).toBeRendered();
}
return new RenderedTestMessageDialog(dialogOut);
}
/** Returns an object representation of (selected) output */

@@ -168,0 +206,0 @@ getOutputDump(...select) {

1

dist/TestCase.d.ts

@@ -238,2 +238,3 @@ import { Assertion } from "./Assertion.js";

expectOutputAsync(timeout: number, ...select: OutputSelectFilter[]): Promise<OutputAssertion>;
expectMessageDialogAsync(timeout: number, ...match: Array<string | RegExp>): Promise<import("./renderer/TestRenderer.js").RenderedTestMessageDialog>;
/** Runs this test case (used by {@link TestScope}) */

@@ -240,0 +241,0 @@ runTestAsync(timeout?: number): Promise<void>;

@@ -367,2 +367,14 @@ import { app } from "@desk-framework/frame-core";

}
async expectMessageDialogAsync(timeout, ...match) {
if (!(app.renderer instanceof TestRenderer)) {
throw Error("Test renderer not found, run `useTestContext()` first");
}
this._awaiting++;
try {
return await app.renderer.expectMessageDialogAsync(timeout, ...match);
}
finally {
this._awaiting--;
}
}
/** Runs this test case (used by {@link TestScope}) */

@@ -369,0 +381,0 @@ runTestAsync(timeout = DEFAULT_TIMEOUT) {

4

package.json
{
"name": "@desk-framework/frame-test",
"version": "4.0.0-dev.13",
"version": "4.0.0-dev.14",
"publishConfig": {

@@ -32,3 +32,3 @@ "tag": "next"

"peerDependencies": {
"@desk-framework/frame-core": "4.0.0-dev.13"
"@desk-framework/frame-core": "4.0.0-dev.14"
},

@@ -35,0 +35,0 @@ "devDependencies": {

@@ -18,2 +18,34 @@ import {

export class RenderedTestMessageDialog {
constructor(dialogOutput: OutputAssertion) {
this.labels.push(...dialogOutput.containing({ type: "label" }).elements);
this.buttons.push(...dialogOutput.containing({ type: "button" }).elements);
}
labels: TestOutputElement[] = [];
buttons: TestOutputElement[] = [];
async clickAsync(button: string) {
for (let b of this.buttons) {
if (b.text === button) return this._click(b);
}
this._click();
}
async confirmAsync() {
return this._click(this.buttons[0]);
}
async cancelAsync() {
let button = this.buttons[this.buttons.length - 1];
return this._click(button);
}
private async _click(button?: TestOutputElement) {
if (!button) throw Error("Message dialog button not found");
button?.click();
return Promise.resolve().then(() => Promise.resolve());
}
}
/**

@@ -194,2 +226,16 @@ * A class that represents an in-memory application render context

async expectMessageDialogAsync(
timeout: number,
...match: Array<string | RegExp>
) {
let dialogOut = await this.expectOutputAsync(timeout, {
accessibleRole: "alertdialog",
});
dialogOut.getSingle();
for (let m of match) {
dialogOut.containing({ type: "label", text: m }).toBeRendered();
}
return new RenderedTestMessageDialog(dialogOut);
}
/** Returns an object representation of (selected) output */

@@ -196,0 +242,0 @@ getOutputDump(...select: OutputSelectFilter[]) {

@@ -394,2 +394,20 @@ import { app } from "@desk-framework/frame-core";

async expectMessageDialogAsync(
timeout: number,
...match: Array<string | RegExp>
) {
if (!(app.renderer instanceof TestRenderer)) {
throw Error("Test renderer not found, run `useTestContext()` first");
}
this._awaiting++;
try {
return await (app.renderer as TestRenderer).expectMessageDialogAsync(
timeout,
...match,
);
} finally {
this._awaiting--;
}
}
/** Runs this test case (used by {@link TestScope}) */

@@ -396,0 +414,0 @@ runTestAsync(timeout = DEFAULT_TIMEOUT) {

@@ -101,2 +101,28 @@ import {

});
test("Alert dialog can be dismissed", async (t) => {
let p = app.showAlertDialogAsync("Foo");
let dialog = await t.expectMessageDialogAsync(100, "Foo");
await dialog.confirmAsync();
let result = await p;
expect(result).toBeUndefined();
});
test("Confirm dialog can be cancelled", async (t) => {
let p = app.showConfirmDialogAsync("Foo?");
await (await t.expectMessageDialogAsync(100, /^Foo/)).cancelAsync();
let result = await p;
expect(result).toBeFalsy();
});
test("Confirm dialog can be confirmed", async (t) => {
let p = app.showConfirmDialogAsync((d) => {
d.messages = ["Foo?", "Bar?"];
d.confirmLabel = "Yes";
});
let dialog = await t.expectMessageDialogAsync(10, /Foo/, /Bar/);
await dialog.clickAsync("Yes");
let result = await p;
expect(result).toBeTruthy();
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc