mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00

* Update api/node/typescript/models.ts Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev> * Code review feedback --------- Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
42 lines
1 KiB
TypeScript
42 lines
1 KiB
TypeScript
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
import test from "ava";
|
|
|
|
import { private_api, Window } from "../dist/index.js";
|
|
|
|
test("Window constructor", (t) => {
|
|
t.throws(
|
|
() => {
|
|
new private_api.Window();
|
|
},
|
|
{
|
|
code: "GenericFailure",
|
|
message: "Window can only be created by using a Component.",
|
|
},
|
|
);
|
|
});
|
|
|
|
test("Window show / hide", (t) => {
|
|
const compiler = new private_api.ComponentCompiler();
|
|
const definition = compiler.buildFromSource(
|
|
`
|
|
|
|
export component App inherits Window {
|
|
width: 300px;
|
|
height: 300px;
|
|
}`,
|
|
"",
|
|
);
|
|
t.not(definition.App, null);
|
|
|
|
const instance = definition.App!.create();
|
|
t.not(instance, null);
|
|
|
|
const window = instance!.window();
|
|
t.is(window.visible, false);
|
|
window.show();
|
|
t.is(window.visible, true);
|
|
window.hide();
|
|
t.is(window.visible, false);
|
|
});
|