forked from webviewjs/webview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhigh_level.test.ts
More file actions
67 lines (56 loc) · 2.06 KB
/
high_level.test.ts
File metadata and controls
67 lines (56 loc) · 2.06 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { describe, test, expect, beforeAll, afterAll } from 'bun:test';
import { Application, ControlFlow, Theme, getWebviewVersion, ProgressBarStatus } from '../index';
// Shared application instance to avoid GTK singleton conflicts
let app: Application;
// Skip Application instantiation in CI because GTK initialization is very slow
const isInCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
describe('High-Level API', () => {
test('getWebviewVersion returns a string', () => {
const version = getWebviewVersion();
console.log('Webview Version:', version);
expect(typeof version).toBe('string');
});
test.skipIf(isInCI)('Application instantiation', () => {
app = new Application({
controlFlow: ControlFlow.Poll,
});
expect(app).toBeDefined();
expect(typeof app.run).toBe('function');
});
test.skipIf(isInCI)('BrowserWindow creation and properties', () => {
const win = app.createBrowserWindow({
title: 'High-Level Test Window',
width: 1024,
height: 768,
resizable: true,
decorations: true,
});
expect(win).toBeDefined();
// These might return defaults if window isn't created yet
expect(typeof win.title).toBe('string');
expect(win.isResizable()).toBe(true);
expect(win.isDecorated()).toBe(true);
});
test.skipIf(isInCI)('Monitor API', () => {
const win = app.createBrowserWindow();
const primary = win.getPrimaryMonitor();
if (primary) {
expect(primary.scaleFactor).toBeGreaterThan(0);
expect(primary.size.width).toBeGreaterThan(0);
}
const available = win.getAvailableMonitors();
expect(Array.isArray(available)).toBe(true);
if (available.length > 0) {
expect(available[0].size.width).toBeGreaterThan(0);
}
});
test.skipIf(isInCI)('Window actions (setters)', () => {
const win = app.createBrowserWindow();
win.setTitle('New Title');
// Testing the merged ProgressBarState (interface + enum)
win.setProgressBar({
status: ProgressBarStatus.Normal,
progress: 50,
});
});
});