mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 12:54:45 +00:00

- Instead of building index.js with esbuild and generating types with tsc, use tsc to build index.js and index.d.ts. - Use ts-node instead of swc for typescript based tests, as that works with es modules. - Remove "syntax_check" target from package.json as that's now implied with "compile". - Sadly this requires one "as any" cast as tsc somehow fails to determine the right type info for node-fetch. Unfortunately index.js can't be an ES module without breaking compatiblity. It would imply that the Node.js port can't be used with require() anymore. So even thought that would simplify things further, it's not part of this PR.
38 lines
983 B
TypeScript
38 lines
983 B
TypeScript
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
|
|
|
import test from 'ava'
|
|
|
|
import { private_api, Window } from '../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) => {
|
|
let compiler = new private_api.ComponentCompiler;
|
|
let definition = compiler.buildFromSource(`
|
|
|
|
export component App inherits Window {
|
|
width: 300px;
|
|
height: 300px;
|
|
}`, "");
|
|
t.not(definition, null);
|
|
|
|
let instance = definition!.create();
|
|
t.not(instance, null);
|
|
|
|
let window = instance!.window();
|
|
t.is(window.visible, false);
|
|
window.show();
|
|
t.is(window.visible, true);
|
|
window.hide();
|
|
t.is(window.visible, false);
|
|
})
|