-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
widget()
control not accepting any specific widget properties
- Loading branch information
Showing
3 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/// <reference path="../../../lib/openrct2.d.ts" /> | ||
|
||
import { widget } from "@src/elements/controls/widget"; | ||
import { window } from "@src/windows/window"; | ||
import test from "ava"; | ||
import Mock from "openrct2-mocks"; | ||
|
||
|
||
test("Standard properties are set", t => | ||
{ | ||
const mock = Mock.ui(); | ||
globalThis.ui = mock; | ||
|
||
const callback = (): void => {}; | ||
const template = window({ | ||
width: 100, height: 100, padding: 10, | ||
content: [ | ||
widget({ | ||
type: "button", | ||
width: "50%", | ||
text: "Click me!", | ||
tooltip: "Best button in the world", | ||
isPressed: true, | ||
onClick: callback, | ||
// @ts-expect-error These properties should be skipped | ||
isVisible: true, x: 25, y: 3421, name: "bob", isDisabled: true | ||
}) | ||
] | ||
}); | ||
template.open(); | ||
|
||
const result = mock.createdWindows[0].widgets[0] as ButtonDesc; | ||
t.is(result.type, "button"); | ||
t.is(result.text, "Click me!"); | ||
t.is(result.tooltip, "Best button in the world"); | ||
t.is(result.x, 10); | ||
t.is(result.y, 25); | ||
t.is(result.width, 40); | ||
t.is(result.height, 65); | ||
t.is(result.onClick, callback); | ||
t.true(result.isPressed); | ||
|
||
t.not(result.name, "bob"); | ||
t.falsy(result.isVisible); | ||
t.falsy(result.isDisabled); | ||
}); |