@gjsify/adwaita-web 0.64.0 → 0.64.1-next.241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -262,6 +262,102 @@ export const GtkWindowTest = async () => {
262
262
  await driveWindowVectors(webSubject, { describe, it, expect }, WINDOW_VECTORS);
263
263
  dispose();
264
264
 
265
+ await describe('<gtk-window> GObject door', async () => {
266
+ await it('a close-request handler returning true is preventDefault', async () => {
267
+ const { el, host } = mount();
268
+ let later = 0;
269
+ el.connect('close-request', () => true);
270
+ el.addEventListener('close-request', () => void later++);
271
+ expect(el.close()).toBe(false);
272
+ expect(el.isConnected).toBe(true);
273
+ expect(later).toBe(0);
274
+ host.remove();
275
+ });
276
+
277
+ await it('a handler that returns nothing lets the default run', async () => {
278
+ const { el, host } = mount();
279
+ let seen = 0;
280
+ el.connect('close-request', () => void seen++);
281
+ expect(el.close()).toBe(true);
282
+ expect(seen).toBe(1);
283
+ expect(el.isConnected).toBe(false);
284
+ host.remove();
285
+ });
286
+
287
+ await it('connect hands the window to the handler and disconnect removes it', async () => {
288
+ const { el, host } = mount();
289
+ let seen: unknown[] = [];
290
+ const id = el.connect('notify::title', (emitter) => void seen.push(emitter));
291
+ el.title = 'a';
292
+ expect(seen).toStrictEqual([el]);
293
+ el.disconnect(id);
294
+ el.title = 'b';
295
+ expect(seen.length).toBe(1);
296
+ host.remove();
297
+ });
298
+
299
+ await it('notify::is-active and notify::maximized are connectable', async () => {
300
+ const { el, host } = mount();
301
+ let maximized = 0;
302
+ el.connect('notify::is-active', () => {});
303
+ el.connect('notify::maximized', () => void maximized++);
304
+ el.maximize();
305
+ expect(maximized).toBe(1);
306
+ host.remove();
307
+ });
308
+
309
+ await it('an undeclared signal is refused by name', async () => {
310
+ const { el, host } = mount();
311
+ let message = '';
312
+ try {
313
+ el.connect('map', () => {});
314
+ } catch (error) {
315
+ message = (error as Error).message;
316
+ }
317
+ expect(message.includes("'map'")).toBe(true);
318
+ host.remove();
319
+ });
320
+
321
+ await it("emit('close-request') is refused, close() is the way", async () => {
322
+ const { el, host } = mount();
323
+ let message = '';
324
+ try {
325
+ el.emit('close-request');
326
+ } catch (error) {
327
+ message = (error as Error).message;
328
+ }
329
+ expect(message.includes('close()')).toBe(true);
330
+ host.remove();
331
+ });
332
+
333
+ await it('is_active and focus_widget are properties, as in GJS', async () => {
334
+ const { el, host } = mount();
335
+ const button = document.createElement('button');
336
+ el.append(button);
337
+ await Promise.resolve();
338
+ expect(typeof el.is_active).toBe('boolean');
339
+ expect(el.get_property('is-active')).toBe(el.is_active);
340
+ el.focus_widget = button;
341
+ expect(el.focus_widget).toBe(button);
342
+ expect(el.get_property('focus-widget')).toBe(button);
343
+ el.set_property('title', 'x');
344
+ expect(el.title).toBe('x');
345
+ host.remove();
346
+ });
347
+
348
+ await it('is-active is read-only through set_property', async () => {
349
+ const { el, host } = mount();
350
+ let message = '';
351
+ try {
352
+ el.set_property('is-active', true);
353
+ } catch (error) {
354
+ message = (error as Error).message;
355
+ }
356
+ expect(message.includes('read-only')).toBe(true);
357
+ host.remove();
358
+ });
359
+ });
360
+
265
361
  await describe('<gtk-window> state members', async () => {
266
362
  await it('a frame that was never connected is not realized: close() does nothing', async () => {
267
363
  const el = document.createElement('gtk-window') as GtkWindow;
@@ -278,7 +374,7 @@ export const GtkWindowTest = async () => {
278
374
  const before = el.isActive;
279
375
  expect(before).toBe(document.hasFocus());
280
376
  el.hidden = true;
281
- expect(el.is_active()).toBe(false);
377
+ expect(el.is_active).toBe(false);
282
378
  el.present();
283
379
  expect(el.isActive).toBe(document.hasFocus());
284
380
  // Every transition above is one notification at most, and none repeats a value.
@@ -429,4 +429,30 @@ export const AdwNavigationViewTest = async () => {
429
429
  host.remove();
430
430
  });
431
431
  });
432
+
433
+ await describe('<adw-navigation-view> GJS-spelled API and declared signals', async () => {
434
+ await it('push_by_tag and get_visible_page_tag follow the camelCase members', () => {
435
+ const { adapter, view, host, page } = mountView();
436
+ adapter.add(page('root'));
437
+ adapter.add(page('detail'));
438
+ expect(view.push_by_tag('detail')).toBe(true);
439
+ expect(view.get_visible_page_tag()).toBe('detail');
440
+ host.remove();
441
+ });
442
+
443
+ await it('connects `pushed` and `notify::visible-page`', () => {
444
+ const { adapter, view, host, page } = mountView();
445
+ adapter.add(page('root'));
446
+ adapter.add(page('detail'));
447
+ const api = view as unknown as { connect(s: string, h: () => void): number };
448
+ let pushed = 0;
449
+ let visible = 0;
450
+ api.connect('pushed', () => pushed++);
451
+ api.connect('notify::visible-page', () => visible++);
452
+ view.push_by_tag('detail');
453
+ expect(pushed).toBe(1);
454
+ expect(visible).toBeGreaterThan(0);
455
+ host.remove();
456
+ });
457
+ });
432
458
  };